目录

Docker笔记-安装配置

dcoker Install

ubuntu

安装文档

Uninstall old versions

sudo apt-get remove docker docker-engine docker.io containerd runc

Install using the repository

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo apt-key fingerprint 0EBFCD88

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

INSTALL DOCKER ENGINE

1
2
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Verify

sudo docker run hello-world

将登陆用户添加到docker用户组

1
2
3
sudo gpasswd -a $USER docker
newgrp docker
docker ps

CentOS

Uninstall old versions

1
2
3
4
5
6
7
8
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

INSTALL DOCKER ENGINE

1
2
3
4
5
sudo yum install -y yum-utils
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io

将非root登陆用户添加到docker用户组

1
2
3
sudo gpasswd -a $USER docker
newgrp docker
docker ps

配置

docker镜像加速

/etc/docker/daemon.json(Linux)

1
2
3
{
  "registry-mirrors": ["https://registry.docker-cn.com", "https://docker.mirrors.ustc.edu.cn"]
}

sudo systemctl restart docker 重启生效

增加到随机启动项

systemctl enbale docker

启动docker

service docker start

docker GUI

  1. kitematic
  2. portainer 轻量级的Docker管理面板
1
docker pull portainer/portainer
1
2
3
4
5
docker run -p 9000:9000 -p 8000:8000 --name portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /mydata/portainer/data:/data \
-d portainer/portainer

安装docker-compose

pip3 install docker-compose