Ubuntu 在线 安装 Docker
bash
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
开启国内镜像加速
修改 /etc/docker/daemon.json 文件(若无自己创建),修改为如下形式
json
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
bash
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker info
开启docker 远程访问API
bash
sudo vim /lib/systemd/system/docker.service
# 找到ExecStart
将 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H
# 修改为
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
# 保存退出。
bash
sudo systemctl daemon-reload
sudo systemctl restart docker
bash
curl http://ip:2375/version