-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
51 lines (35 loc) · 1.12 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Dockerfile, Image, Container
# base image
FROM python:3
# work envornment variable
ENV DockerHOME=/home/app/webapp
# work directory
RUN mkdir -p $DockerHOME
# where the code will be contained
WORKDIR ${DockerHOME}
# environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# update pip to the latest version
RUN pip install --upgrade pip
# copy whole project to your docker home directory.
COPY . $DockerHOME
# run this command to install all dependencies
RUN pip install -r requirements.txt
# port where the Django app runs
EXPOSE 8000
# CMD command for the docker image
CMD [ "python3", "manage.py", "runserver", "0.0.0.0:8000" ]
# Command to build container using docker:
# docker build -t image_name .
# Get images:
# docker image ls
# Command to start container:
# docker run container_name image_name
# or docker run -t -i image_name when user input is needed
# !! Running an image with porting is needed, therefore use the command:
# docker run -d -p 8000:8000 image_name
# Get containers:
# docker container ls
# Container execution command:
# docker exec -i -t container_id command