Docker卷集,但代码未更新代码

时间:2019-03-22 17:21:35

标签: docker dockerfile docker-volume

对于正在构建的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>

但仍然无法识别我没有先构建就进行查看的更改

由于我缺少有关如何定义音量的信息。我正在尝试使更改可见,而无需重新构建并运行

0 个答案:

没有答案