本文将介绍在各linux系统下安装docker的方法
ubuntu:18.04
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt update
如果之前安装过,需要先进行卸载
apt -y install docker-ce docker-ce-cli containerd.io
默认安装的是最新版本sudo apt-cache madison docker-ce
apt-cache madison docker-ce
apt install -y docker-ce=18.06.3~ce~3-0~ubuntu
service docker start
apt autoremove -y docker-ce docker-ce-cli docker-engine docker.io containerd runc --purge
centos:7.5
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
也可以使用阿里云的仓库http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
如果之前安装过,需要先进行卸载
yum install -y docker-ce
默认安装最新版
yum list docker-ce --showduplicates | sort -r
yum install -y docker-ce-18.06.3.ce
yum-config-manager --add-repo https://nvidia.github.io/nvidia-docker/centos7/x86_64/nvidia-docker.repo
yum install -y nvidia-docker2
systemctl start docker
yum remove docker-selinux
找一台能联网的电脑
下载地址
如下载
docker-18.03.1-ce版本,将下载为docker-18.03.1-ce.tgz文件
发送到目标主机
解压
tar -zxvf docker-18.03.1-ce.tgz
将解压得到
docker文件夹
将docker文件夹的执行文件复制到/usr/bin路径下
cp docker/* /usr/bin/
创建docker.service文件
vim /usr/lib/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
# 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
systemctl start docker