请问这是必须的么,如果是这样的话,是要用docker compose-up 自动简化这个过程?
如果不是必须的话,因为我的dockerfile的问题么?
dockerfile如下:
FROM ubuntu
MAINTAINER Tarty.Phoenix <tartyphoenix@gmail.com>
RUN apt-get update
RUN apt-get install -y -q python-all python-pip libffi-dev
RUN apt-get install -y -q python-dev build-essential
ADD ./flask_pure/requirements.txt /tmp/requirements.txt
RUN pip install -qr /tmp/requirements.txt
ADD ./flask_pure /opt/flask_pure/
WORKDIR /opt/flask_pure
EXPOSE 80
CMD ["python", "manage.py", "runserver"]
First of all, the directory represented by workdir is the directory in the container, not the host.
The following content changes require rebuilding the image
Dockerfile itself changes
Source file changes for COPY / ADD instructions
docker-compose supports re-building the image during operation
There is one point in your question that I need to explain to you.
After creating and editing the dockerfile, build creates an image (mirror), and then runs an image to generate a container (container). Then the image and container have a one-to-one correspondence. Then when you edit the dockerfile and change the workdir, the container you create will of course enter the new workdir by default. Therefore, the title of your question should not describe a question, but a correct logical description.
Your understanding of docker is wrong. What you do is just packaging the contents of a certain folder into an image.
It is recommended that you understand the concept of VOLUME volume in docker. Only by specifying the -v parameter when starting the container or specifying the VOLUME parameter in docker-compose.yml can the container mount the local directory.
So how to distinguish whether the container needs to be mounted to the local directory? My understanding is whether it is in development status or production status.
If you are in a development state and the code needs to change frequently, it is difficult to accept that every time the code is modified, it needs to be repackaged into the image.
If you are in production, imagine that there are so many images on Docker Hub. If these images provide you with an installation environment and source code, then you need to manually specify the VOLUME to mount the source code directory, and then start the container. I will compile and install it. What do you think of this experience?