首页 > 解决方案 > Docker 卷集但代码不更新代码

问题描述

我正在构建的 django 应用程序有以下 Dockerfile

# base image to be used
FROM python:3.6
# The enviroment variable ensures that the python output is set straight
# to the terminal with out buffering it first
ENV PYTHONUNBUFFERED 1

# create root directory for our project in the container
#RUN mkdir /code

# Set the working directory to the created dir
WORKDIR /code

# add the requiremnets file to the working dir
COPY requirements.txt /code/

#instal the requirements (install before adding rest of code to avoid rerunning this at every code change-built in layers)
RUN pip3 install -r requirements.txt

# Copy the current directory contents into the container at /music_service
COPY . /code/

#set environments to be used
ENV AUTHOR="Mokgadi Rasekgala "

EXPOSE 8000

VOLUME /code

#run the service docker app
CMD /code/start.sh

当我构建文件并使用以下命令运行它时

docker run -it -p 8000:8000 <image>

该卷似乎没有安装在 /code 目录上

我也尝试运行它

docker run -it -v my-vol:/code -p 8000:8000 <image>

但也仍然无法识别我在没有首先构建的情况下对视图所做的更改

因为我在如何定义音量方面缺少一些东西。我正在尝试使更改可见,而无需再次构建和运行

标签: dockerdockerfiledocker-volume

解决方案


推荐阅读