赞
踩
# 首先,使用yum remove docker* 移除之前安装的docker yum remove docker* # 配置yum源 sudo yum install -y yum-utils sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 下面这个命令是将软件包信息提前在本地缓存一份,用来提高搜索安装软件的速度 sudo yum makecache fast # 安装docker sudo yum install -y docker-ce docker-ce-cli containerd.io # 启动Docker服务 systemctl start docker # 设置开机自动启动 systemctl enable docker # 测试 docker run hello-world # 卸载的命令 sudo yum remove docker-ce docker-ce-cli containerd.io # 软件卸载后,Docker默认的工作路径是/var/lib/docker 需要执行rm命令把这个工作路径删除 rm -rf /var/lib/docker # 阿里云镜像加速配置 sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://g090nq5l.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
tar -zxvf docker-23.0.1.tgz
cp -p docker/* /usr/bin
① 在/usr/lib/systemd/system/目录下,创建docker.service文件
vim /etc/systemd/system/docker.service
② 编辑docker.service文件
注:以下内容中 --insecure-registry=192.168.3.10 此处改为你自己服务器ip。
[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 --selinux-enabled=false --insecure-registry=192.168.3.10 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
重启守护进程
# 给予权限
chmod 777 /etc/systemd/system/docker.service
# 重启守护进程
systemctl daemon-reload
# 启动docker
systemctl start docker
# 查看docker状态
systemctl status docker
# 设置开机自启动
systemctl enable docker
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。