一.在线安装
1.安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
2.添加软件源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3.安装docker-ce
yum -y install docker-ce
4.启动服务
systemctl start docker
5.查看docker版本信息
docker version
二.离线安装
1.登录镜像网站
https://download.docker.com/linux/static/stable/x86_64/
2.解压
tar -xvf docker-18.06.1-ce.tgz
3.把解压出来的文件移动到/usr/bin 目录下
cp docker/* /usr/bin/
4.将docker注册为service
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 # 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
5.启动
chmod +x /etc/systemd/system/docker.service systemctl daemon-reload systemctl start docker systemctl enable docker.service 原文:https://blog.csdn.net/ywd1992/article/details/82897394
6.安装好的docker没有补全,从其他服务器拷贝一份docker
ll /usr/share/bash-completion/completions/docker
7.将docker文件放置相同路径下,并生效
source /usr/share/bash-completion/completions/docker