我对其中一项服务的 Dockerfile 进行了一些更新,但这些更改在运行时没有反映出来docker-compose build
,甚至在使用--no-cache
选项时也没有反映出来。
我在运行之前添加了两个两个参数pip install -f requirements.txt
,但它们不会在任何时候执行:它直接进入需求步骤。
$ docker-compose build --no-cache
mongo uses an image, skipping
postgres uses an image, skipping
elasticsearch uses an image, skipping
Building nucleo
Step 1/9 : FROM python:3.6
---> 2bb3204ab1d1
Step 2/9 : COPY core/ /container_core/
---> cc1eadcb80a3
Step 3/9 : WORKDIR /container_core
---> Running in e8afa25b9c9a
Removing intermediate container e8afa25b9c9a
---> f9b928dee6f5
Step 4/9 : RUN pip install -r requirements.txt
---> Running in 84f474edb526
^CERROR: Aborting.
码头工人-compose.yml
services:
mongo:
image: "mongo:4.0.5"
container_name: compose_mongo
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=mongo
- MONGO_INITDB_ROOT_PASSWORD=mongopass
ports:
- "27017:27017"
core:
build:
context: /home/ivanleoncz/git/core
dockerfile: Dockerfile
container_name: compose_core
depends_on:
- mongo
env_file:
- .env
ports:
- "8000:8000"
Dockerfile
FROM python:3.6
COPY core/ /container_core/
WORKDIR /container_core
# must run before requirements
RUN pip install --upgrade pip
RUN pip install urllib3=1.20
# then, run the requirements
RUN pip install -r requirements.txt
CMD ["python3", "manage.py", "makemigrations", "app1"]
CMD ["python3", "manage.py", "makemigrations", "app2"]
CMD ["python3", "manage.py", "makemigrations", "app3"]
CMD ["python3", "manage.py", "migrate"]
CMD ["python3", "manage.py", "runserver"]
我正在使用 docker-compose 1.21.2 和 Ubuntu 18.04.2。
我如何保证docker-compose
没有使用旧版本的 Dockerfile,即使我描述的是我想要执行构建,没有任何缓存(--no-cache
)?