Reputation: 145
with a dockerfile like so
FROM python:3.5.5-alpine
ARG CONTAINER_HOME_DIR
ENV CONTAINER_HOME_DIR=$CONTAINER_HOME_DIR
WORKDIR $CONTAINER_HOME_DIR
COPY wall_e/src/requirements.txt .
RUN apk add --update alpine-sdk libffi-dev && \
apk add freetype-dev && \
apk add postgresql-dev && \
pip install --no-cache-dir Cython && \
pip install --no-cache-dir -r requirements.txt && \
apk --update add postgresql-client
COPY wall_e/src ./
CMD ["./wait-for-postgres.sh", "db", "python", "./main.py" ]
If I then use this dockerfile with docker-compose
, at what point does docker-compose determine that it needs to re-create the docker image that it will use to make the docker container from that image?
Will it remake the docker image if I make changes to the wall_e/src/requirements.txt
file or will it remake the docker image if I make a change to the RUN
line or the make a change to any files located in wall_e/src
or even change the COPY
LINE entirely or the CMD
line?
Lets assume that I am using docker-compose up
and I am not using the option --force-recreate
Upvotes: 0
Views: 93
Reputation: 9988
Docker will not rebuild images unless 1) instructed to do so, or 2) if the named image doesn’t exist.
That being said, when you rebuild, it will attempt to rebuild based on any cached information it has, and does not re-process steps unless the dockerfile has been modified, or if a file referenced via COPY
has been modified. Any subsequent steps after a re-processed step will also be re-processed, because the build process basically creates new sub-images based on sub-images built from previous steps in the dockerfile.
However, if you specify —no-cache
, it will re-process all steps in the dockerfile.
Upvotes: 1
Reputation: 11943
Once the image is built, docker-compose will not look into your dockerfile.
It will use that image, and only apply its configuration (docker-compose.yml
).
So let's say you docker-compose up
, then edit your docker-compose.yml
file, your requirements.txt
and your dockerfile
, when you use docker-compose restart
only the docker-compose.yml changes will be taken into account.
If you need to rebuild your image, you'll have to use specifically :
docker-compose build [my_service]
Upvotes: 1