To establish my Django project in Docker, I have done following work.
make image
I make image by Dockfile.
create Dockfile at the root of your project.
the content of Dockerfile:
FROM fw-registry.dev.fwmrm.net/ubuntu
LABEL description="web compare tool" \
maintainer="****"
WORKDIR /webCompareTool
# COPY . /webCompareTool/requirements.txt
RUN apt-get -qq update
RUN apt-get -qq install python
RUN apt-get -qq -y install python-pip
RUN pip install --upgrade pip
RUN pip install django
RUN pip install bs4
RUN pip install selenium
RUN pip install html2text
RUN pip install pillow
RUN pip install diff_match_patch
RUN apt-get -qq -y install wget
RUN apt-get -qq -y install unzip
RUN wget https://chromedriver.storage.googleapis.com/2.40/chromedriver_linux64.zip
RUN unzip chromedriver_linux64.zip
RUN ls
RUN chmod 777 chromedriver
RUN cp chromedriver /usr/bin/
RUN apt-get -qq install chromium-browser
ADD . /webCompareTool/
EXPOSE 5000
RUN python ComDetailPage/manage.py migrate
The rule of Dockfile, follow this https://yeasy.gitbooks.io/docker_practice/image/build.html
Then, build it at the Dockerfile directory.
docker buil web-compare-tool .
Then run ‘docker images’ to see the images you have.
docker images
test running image
To assure our image can run smoothly, we should run the local image firstly, by the command ‘docker run’, for my case, the command to run my project is
docker run -it -p 5000:5000 web-compare-tool python ComDetailPage/manage.py runserver 0.0.0.0:5000
If success, you can visit your website at http://localhost:5000/index
tag image
Before push the image, we have to tag it.
docker tag image_id[:tag] private_repo/username/image_name[:tag]
push image
Finally, we can push the tagged image into the reposity by
docker push private_repo/username/image_name[:tag]
you will get a url to visit your image after successfully pushing it.