It is also very simple to deploy Django projects using docker. It is very good. Share it below environment By default, you have installed the docker environment Django project general structure (p3s) [root@opsweb]# tree opsweb opsweb ├── apps ├── logs ├── manage.py ├── media ├── opsweb ├── README.md ├── requirements.txt └── static Writing a Dockerfile Here, the Python version is specified as the one provided by Docker officially. "0.0.0.0:8000" Here I open port 8000 in the container FROM python:3.6 RUN mkdir -p /usr/src/app COPY pip.conf /root/.pip/pip.conf COPY opsweb /usr/src/app/ COPY run_web.sh /usr/src/app/ RUN pip install -r /usr/src/app/requirements.txt WORKDIR /usr/src/app CMD [ "sh", "./run_web.sh"] Writing pip files Here is to use the mirror pip install faster using Alibaba Cloud source [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com Complete directory structure [root@opsweb]# ls Dockerfile opsweb pip.conf run_web.sh Build image docker build -t ops:v0.1 . Sending build context to Docker daemon 4.849 MB Step 1: FROM python:3.6 ---> 3e4c2972dc8d Step 2 : RUN mkdir -p /usr/src/app ---> Running in 8ddd929f5c18 ---> 89dc0a1ffdf0 Removing intermediate container 8ddd929f5c18 Step 3 : COPY pip.conf /root/.pip/pip.conf ---> 5a4a165fed90 Removing intermediate container 37f3fdc7e5d2 Step 4: COPY opsweb /usr/src/app/opsweb ---> f602e72ffd4c Removing intermediate container 8d4bb616916d Step 5: COPY opsweb/requirements.txt /usr/src/app/ ---> 6fe11a6fcbe0 Removing intermediate container faeadee32fed Step 6 : RUN pip install -r /usr/src/app/requirements.txt ---> cc09c17d53da Removing intermediate container d7b45bec6993 Step 7: WORKDIR /usr/src/app ---> Running in c22dfdddbe81 ---> c5c944b6df45 Removing intermediate container c22dfdddbe81 Step 8 : CMD python ./manage.py runserver 0.0.0.0:8000 ---> Running in 29d5f0f53f6e ---> 10d37173fd13 Removing intermediate container 29d5f0f53f6e Successfully built 10d37173fd13 Conclusion In this way, the image is built, and then you can directly start it with docker run -p8000:8000 ops:v0.1 -d, or you can deploy it to k8s, which is also very simple and I will not go into details here. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Summary of Commonly Used MySQL Commands in Linux Operating System
>>: Correct way to load fonts in Vue.js
Table of contents 1. Boolean 2. Expression 3. Mul...
Recommended Docker learning materials: https://ww...
What is bond NIC bond is a technology that is com...
Table of contents 1.setInterval() 2.setTimeout() ...
Since the project requires a questionnaire, but th...
Below are some common parameters of /etc/my.cnf o...
1. Custom text selection ::selection { background...
In Linux, everything is a file, so the Android sy...
View the nginx configuration file path Through ng...
This article uses examples to describe the common...
This article example shares the specific code of ...
Table of contents 1. Introduction 2. Understand t...
Vuex is a state management pattern developed spec...
This article shares the installation and configur...
Table of contents 1. Props Parent >>> Ch...