docker 不熟,也不常使用,简单记一下可能会用的容器基本的参数命令

docker

  1. 配置国内源

    /etc/docker/daemon.json

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    
    {
      "registry-mirrors": [
        "https://hub-mirror.c.163.com",
        "https://mirror.baidubce.com"
      ]
    }
    or 
    
    {
    "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
    }
    
    
    1
    2
    
    sudo systemctl daemon-reload
    sudo systemctl restart docker
    
  2. sudo

    1
    2
    3
    
    sudo gpasswd -a ${USER} docker
    systemctl restart docker.service #需重启生效
    newgrp - docker	#无需重启
    
  3. 容器–httpd

    1
    
    docker run --name httpdService --restart=always -p 8000:80 -v $PWD/yourpath/:/usr/local/apache2/htdocs/  -d httpd
    
  4. 容器–portainer

    1
    
    docker run -d -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name Portainer-WebUI portainer/portainer
    
  5. 容器– mariadb

    1
    
    docker run -d -p 32680:3306 --name MariaDB-Service -e MYSQL_ROOT_PASSWORD=passwd --restart=always -v /data/Db/mariadb:/var/lib/mysql mariadb