“docker执行”环境不同于“docker运行”/“docker附加”环境?

我最近尝试创build一个用于开发django项目的docker环境。

我注意到,通过Dockerfile创build或复制的文件只有在使用“docker run”或“docker attach”时才可以访问,在这种情况下,对于后者,您将能够进入并查看您移动到的任何文件他们适当的地方。

但是,运行“docker exec”时,容器似乎没有显示任何这些文件的任何跟踪。 为什么发生这种情况?

Dockerfile

############################################################ # Dockerfile to run a Django-based web application # Based on an Ubuntu Image ############################################################ # Set the base image to use to Ubuntu FROM ubuntu:14.04 # Set env variables used in this Dockerfile (add a unique prefix, such as DOCKYARD) # Local directory with project source ENV DOCKYARD_SRC=hello_django # Directory in container for all project files ENV DOCKYARD_SRVHOME=/srv # Directory in container for project source files ENV DOCKYARD_SRVPROJ=/srv/hello_django # Update the default application repository sources list RUN apt-get update && apt-get -y upgrade RUN apt-get install -y python python-pip # Create application subdirectories WORKDIR $DOCKYARD_SRVHOME RUN sudo mkdir media static logs # Copy application source code to SRCDIR COPY $DOCKYARD_SRC $DOCKYARD_SRVPROJ # Install Python dependencies RUN pip install -r $DOCKYARD_SRVPROJ/requirements.txt # Port to expose EXPOSE 8000 # Copy entrypoint script into the image WORKDIR $DOCKYARD_SRVPROJ COPY ./docker-entrypoint.sh / 

通过上面的Dockerfile,我的源文件夹hello_django被复制到/ srv / hello_django中的适当位置,并且我的docker-entrypoint.sh也成功移到了根目录。

例如,我可以在“docker run -it bash”/“docker attach”中确认这一点,但不能通过“docker exec -it bash”访问它们中的任何一个。

(从本教程中获得的Dockerfile)。

问题示范

问题的图像certificatehttp://img.gdocker.com/django/2b72ddaeebc44a1cb517f2d8f20d4668.png

如果这是相关的,我通过stream浪汉运行docker工人。

Vagrantfile

 config.vm.box = "hashicorp/precise64" config.vm.network "forwarded_port", guest: 8000, host: 8000 config.vm.provision "docker" do |d| d.pull_images "django" end