1.更新镜像源并安装依赖
apt update && apt upgrade -y
apt -y install ipvsadm ipset apt-transport-https
apt -y install ca-certificates curl software-properties-common apt-transport-https
2.安装docker
#step 1: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 2: 写入软件源信息
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 3: 更新并安装 Docker-CE
apt-get -y update
# Step 3: 查看存在的版本信息
apt-cache madison docker-ce
apt-get install docker-ce=<VERSION_STRING>
3.配置docker
(1). mkdir /etc/systemd/system/docker.service.d
vim /etc/systemd/system/docker.service.d/private-registry.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock --insecure-registry IP:port
–insecure-registry 指私有的docker 仓库的地址
(2). 配置 docker 加速器
vim /etc/docker/daemon.json
{
"log-driver": "json-file",
"exec-opts": ["native.cgroupdriver=cgroupfs"],
"log-opts": {
"max-size": "100m",
"max-file": "3"
},
"live-restore": true,
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 10,
"registry-mirrors": ["https://hccwwfjl.mirror.aliyuncs.com"],
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
(3). 配置docker 代理
vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http:/" "HTTPS_PROXY=http:/"
(4). 加载配置信息并重启docker
systemctl daemon-reload
systemctl restart docker
(5). 查看docker 基本信息
docker info