docker 部署django服务流程

1:安装docker

2:利用docker安装centos

3: 查看docker中的所有镜像  docker images 

3.1 启动镜像(注意:要在容器中使用system 命令,使用以下命令)

docker run --name=centos7 -itd --network=host -p 8002:80 --privileged=true  centos:7 /usr/sbin/init

注意:关机的时候容器会停掉,停掉的话进行4,5,6步的操作。

4: 查看docker中的所有容器

[root@localhost ~]# docker container ls --all
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
0474888500f2        5badaf4078a9        "/bin/bash"         2 months ago        Exited (137) 2 months ago                       centos7.2
468a5cd9d75d        a61ffb4d2cda        "/bin/bash"         2 months ago        Exited (137) 2 months ago                       centos7.1

5:查看docker 中正在运行的容器

[root@localhost ~]# docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@localhost ~]# docker container ls --all

6:启动容器(后面是ID号),在进行查看是否启动

[root@localhost ~]# docker restart 0474888500f2
0474888500f2
[root@localhost ~]# docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
0474888500f2        5badaf4078a9        "/bin/bash"         2 months ago        Up 35 seconds                           centos7.2
[root@localhost ~]#

7:进入容器

[root@localhost ~]# docker exec -it 0474888500f2 /bin/bash
[root@localhost /]#

8:查看项目目录

[root@localhost Topological]# pwd
/data/web/Topological
[root@localhost Topological]#

9:查看uwsgi配置文件(配置文件是uwsigi.ini)

[root@localhost uwsigi_conf]# pwd   
/data/web/Topological/uwsigi_conf
[root@localhost uwsigi_conf]# 

10:查看nginx 的配置文件(nginx.conf)

[root@localhost conf]# pwd
/usr/local/nginx/conf
[root@localhost conf]# 

  注意:uwsgi 单独启动django和Nginx+uwsgi 启动django是有区别的,详见https://www.cnblogs.com/Live-up-to-your-youth/p/14543443.html,另外初次部署要收集静态文件,在此博客中也有说明,注意事项也有说明

    下面的启动方式是uwsgi+Nginx

11:启动nginx 

/usr/local/nginx/sbin/nginx

12: 启动uwsgi

[root@localhost uwsigi_conf]# uwsgi --ini uwsigi.ini
[uWSGI] getting INI configuration from uwsigi.ini
[root@localhost uwsigi_conf]# 

 

posted on 2021-08-27 16:53  paike123  阅读(353)  评论(0编辑  收藏  举报

导航