我有一个Docker文件,试图将Django代码部署到容器中。
FROM ubuntu:latest
MAINTAINER { myname }
#RUN echo "deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -sc) main universe" >> /etc/apt/sou$
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tar git curl dialog wget net-tools nano buil$
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python python-dev python-distribute python-p$
RUN mkdir /opt/app
WORKDIR /opt/app
#Pull Code
RUN git clone git@bitbucket.org/{user}/{repo}
RUN pip install -r website/requirements.txt
#EXPOSE = ["8000"]
CMD python website/manage.py runserver 0.0.0.0:8000
接下来我使用docker build -t dockerhubaccount/demo:v1 .
命令构建我的代码,这将把我的代码从Bitbucket拉到容器中。然后我使用docker run -p 8000:8080 -td felixcheruiyot/demo:v1
命令运行它,一切似乎都正常。
现在我想要更新代码,因为我使用了git clone ...
命令,所以我有些困惑:
- 当我有新的提交时,我该如何更新我的代码,并在构建Docker容器时自动使用新代码(注意:由于缓存,当我运行构建命令时并不会获取最新代码)?
- 这种情况下最佳的工作流程是什么?
docker exec -it con/tainer bash
,那么将运行bash
而不是在CMD
中指定的任何内容。对我来说,这两个选项都不太理想,这必须是非常常见的问题 - 我觉得应该有一种方法在Dockerfile
的中间禁用缓存。 - avloss