二进制安装docker文档
建模部署
docker安装
下载docker
因rpm包安装依赖较多,选择二进制安装,下载地址如下
https://download.docker.com/linux/static/stable/x86_64/
创建docker组
groupadd docker
如果没有docker组,启动docker将会报如下错误
5月 29 14:40:59 localhost.localdomain systemd[1]: Dependency failed for Docker Application Container Engine.
5月 29 14:40:59 localhost.localdomain systemd[1]: docker.service: Job docker.service/start failed with result 'dependency'.
安装docker
#解压
tar xf docker-20.10.9.tgz
#拷贝二进制文件
cp docker/* /usr/bin/
配置docker启动
- 创建containerd的service文件
#创建containerd的service文件,并且启动
cat >/etc/systemd/system/containerd.service <<EOF
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=1048576
TasksMax=infinity
OOMScoreAdjust=-999[Install]
WantedBy=multi-user.target
EOF
- 启动containerd
systemctl enable --now containerd.service
- 创建docker的service文件
#准备docker的service文件
cat > /etc/systemd/system/docker.service <<EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket containerd.service[Service]
Type=notify
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
OOMScoreAdjust=-500[Install]
WantedBy=multi-user.target
EOF
- 创建docker的socket文件
#准备docker的socket文件
cat > /etc/systemd/system/docker.socket <<EOF
[Unit]
Description=Docker Socket for the API[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker[Install]
WantedBy=sockets.target
EOF
- 启动docker并验证
#启动docker
systemctl enable --now docker.socket && systemctl enable --now docker.service
#验证
docker info
复制代码
- 创建docker配置文件(按需创建)
cat >/etc/docker/daemon.json <<EOF
{"exec-opts": ["native.cgroupdriver=systemd"],"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn","http://hub-mirror.c.163.com"],"max-concurrent-downloads": 10,"log-driver": "json-file","log-level": "warn","log-opts": {"max-size": "10m","max-file": "3"},"data-root": "/var/lib/docker"
}
EOF
systemctl restart docker