docker常用的命令,个人总结。

  1. 最近在使用docker部署项目,和安装应用,下面分享一些常用的docker命令,希望能帮到使用docker的小伙伴们。
  2. 命令:
    **1.启动docker 服务**:
    
    ```
    systemctl start docker
    ```
    
    **2.删除所有容器:**
    
    ```
    docker rm `docker ps -a -q`
    ```
    
    **3.删除所有镜像:**
    
    ```
    docker rmi `docker images -q`
    ```
    
    **4.docker启动所有的容器:**
    
    ```
    docker start $(docker ps -a | awk '{ print $1}' | tail -n +2)
    ```
    
    **5.查看所有容器:**
    
    ```
    docker ps
    ```
    
    **6.重启容器**
    
    ```
    docker container restart 容器名
    ```
    
    **7.启动容器:**
    
    ```
    docker start 容器id
    ```
    
    **8.停止容器:**
    
    ```
    docker stop 容器id
    ```
    
    **9.docker 创建前端容器**
    
    ```
    docker run --name cas-web-client -p 80:8080 -v /home/apps/web/dist/:/usr/local/tomcat/webapps/ROOT -d tomcat:jdk8 
    
    docker run --name ui-builder-client -p 11771:8080 -v /home/ocnadmin/ui-builder/web/dist/:/usr/local/tomcat/webapps/ROOT -d tomcat:jdk8 
    docker run --name ui-builder-manager -p 11772:8080 -v /home/ocnadmin/ui-builder/manager-web/dist/:/usr/local/tomcat/webapps/ROOT -d tomcat:jdk8
    ```
    
    10.进去容器:
    
    ```
    docker exec -it pg9.6 /bin/bash
    ```
    
    11.docker创建pg数据库
    
    docker run --name pg9.6 -v /data/ocn/db/pgsql/:/var/lib/postgresql/data/ -e POSTGRES_PASSWORD=o.cnwx123 -p 5432:5432 -d postgres:9.6
    
    12 nginx部署
    
    ```
    docker run -id \
    -p 11510:11510 \
    -p 11566:11566 \
    --name nginx \
    -v /home/ocnadmin/docker/nginx/html:/usr/share/nginx/html \
    -v /home/ocnadmin/docker/nginx/base/11510:/usr/share/nginx/base/11510 \
    -v /home/ocnadmin/docker/nginx/base/11566:/usr/share/nginx/base/11566 \
    -v /home/ocnadmin/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
    -v /home/ocnadmin/docker/nginx/conf/conf.d:/etc/nginx/conf.d \
    -v /home/ocnadmin/docker/nginx/logs:/var/log/nginx \
    -v /home/ocnadmin/docker/nginx/certs:/etc/nginx/certs \
    docker.io/nginx:latest
    ```
    
    

     

你可能感兴趣的:(docker,发布,工具,docker,centos,服务器,vue.js)