1、Docker 安装 Step by Step

# 1. remove old docker 

sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1)

# 2. install docker 
# Add Docker's official GPG key:
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

# 3. docker 
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

2、config user

#非root用户免sudo使用Docker(一定要做)
sudo gpasswd -a yypan docker  #add yypan to docker group
newgrp docker  #刷新用户组

3、config proxy

sudo touch /etc/docker/daemon.json

添加下面内容
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "ipv6":false,
  "insecure-registries":["172.105.104.177:1080"],
  "data-root":"/opt/docker",
  "registry-mirrors": ["https://docker.1panel.live"]
}

# 重新加载某个服务的配置文件
sudo systemctl daemon-reload
# 重新启动 docker
sudo systemctl restart docker

4、 test

sudo docker run hello-world

5、 more

sudo systemctl status docker

sudo systemctl start docker

sudo systemctl stop docker