二进制安装docker

下载安装docker

wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.6.tgz
tar xf docker-20.10.6.tgz
chown -R root.root docker
cp docker/* /usr/bin/
groupadd docker
mkdir /var/lib/docker /etc/docker

配置文件

vim /etc/docker/daemon.json

{
  "storage-driver": "overlay2",
  "registry-mirrors": ["https://q2gr04ke.mirror.aliyuncs.com"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "live-restore": true,
  "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
}

systemd管理文件

vim /etc/systemd/system/docker.service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
ExecStart=/usr/bin/dockerd  -H tcp://127.0.0.1:2375 -H unix://var/run/docker.sock --graph /var/lib/docker
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

vim /etc/systemd/system/docker.socket

[Unit]
Description=Docker Socket for the API
PartOf=docker.service

[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker

[Install]
WantedBy=sockets.target

启动

systemctl daemon-reload
systemctl start docker
systemctl enable docker

你可能感兴趣的:(docker,docker,容器,运维)