Linux服务器安装Docker
一、前言
Docker是一组平台即服务(PaaS)的产品。它基于操作系统层级的虚拟化技术,将软件与其依赖项打包为容器。托管容器的软件称为Docker引擎。Docker能够帮助开发者在轻量级容器中自动部署应用程序,并使得不同容器中的应用程序彼此隔离,高效工作。该服务有免费和高级版本。
二、Docker安装包下载
三、Docker安装
3.1、创建文件夹
mkdir -p /home/software
3.2、上传安装包
#解压docker
unzip docker.zip
#拷贝docker下文件至/usr/bin/
sudo cp docker/* /usr/bin/
#修改文件名
mv docker-compose-* docker-compose
chmod +x docker-compose
3.3、拷贝docker-compose下文件至/usr/bin/
sudo cp docker-compose /usr/bin/
#查看版本
docker-compose version
3.4、创建docker.service服务
vim /etc/systemd/system/docker.service
#文件内容docker.service
```bash
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
赋予执行权限
sudo chmod +x /etc/systemd/system/docker.service
### 3.5、创建文件夹/etc/docker
mkdir -p /etc/docker/
编辑daemon.json文件
vi /etc/docker/daemon.json
{
"userland-proxy": false
}
### 3.6、赋予执行权限
chmod +x /usr/bin/docker
chmod +x /usr/bin/runc
chmod +x /usr/bin/dockerd
chmod +x /usr/bin/containerd
### 3.7、从新加载文件
sudo systemctl daemon-reload
### 3.8、启动docker
sudo systemctl start docker
systemctl status docker.service
### 3.9、验证

浙公网安备 33010602011771号