代码改变世界

docker 命令整理

2022-09-30 10:05  默默不语  阅读(25)  评论(0编辑  收藏  举报
  1. 查看版本

    docker -v

  2. 列出正在运行的容器

    docker ps

  3. 列出所有容器

    docker ps -a

  4. 启动/停止容器

    docker start/stop containerID

  5. 进入容器

    docker exec -it docker_web_1 /bin/sh

  6. 列出所有镜像

    docker images -a

  7. 容器管理GUI

Home

Container List

  1. 设置代理
    FQ:

    Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
    
    sudo mkdir -p /etc/systemd/system/docker.service.d
    sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf
        [Service]
        Environment="HTTP_PROXY=http://webproxy.bu.edu:8900"
        Environment="HTTPS_PROXY="http://webproxy.bu.edu:8900"
    sudo systemctl daemon-reload
    sudo systemctl restart docker
    
  2. LDAP

    docker run -p 389:389 -p 636:636 --name ldap --detach osixia/openldap
    
  3. PHPAdmin

    • install
      docker run -dit -p 8990:80 --link ldap --name ldapadmin --env PHPLDAPADMIN_HTTPS=false --env PHPLDAPADMIN_LDAP_HOSTS=LDAP --restart always --detach osixia/phpldapadmin
      
    • account
      cn=admin,dc=example,dc=org
      admin
      
  4. docker 查看 container 的 ip

    docker inspect container_id | grep IPAddress

  5. docker nginx reverse proxy

    • How to setup a Docker Nginx reverse proxy server example
      • Start with the official Nginx image

        docker run -d --name nginx-base -p 80:80 nginx:latest

      • Copy the Nginx config file from Docker

        docker cp nginx-base:/etc/nginx/conf.d/default.conf ./default.conf

      • Nginx and Docker reverse proxy configuration

            # Complete Nginx Docker reverse proxy config file
            server {
            listen 80;
            listen [::]:80;
            server_name localhost;
        
            location / {
                root /usr/share/nginx/html;
                index index.html index.htm;
            }
        
            location /sample {
                proxy_pass http://localhost:8080/sample;
            }
        
            error_page 500 502 503 504 /50x.html;
            location = /50x.html {
                root /usr/share/nginx/html;
            }
            } # End of Docker Nginx reverse proxy example file
        
      • Copy the Nginx config file back to Docker

        docker cp ./default.conf nginx-base:/etc/nginx/conf.d/

      • validate and reload the Docker Nginx reverse proxy configuration

        docker exec nginx-base nginx -t
        docker exec nginx-base nginx -s reload