Docker离线部署(centos)

0,下载安装包

wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.5.tgz

1,解压

tar -xvf docker-19.03.5.tgz

2, 将解压出来的docker目录下的文件移动到 /usr/bin/ 目录下

cp docker/* /usr/bin/

3,将docker注册为系统service

vi /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=onfailure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target

4,启动docker

# 添加文件权限并启动docker
chmod u+x /usr/lib/systemd/system/docker.service
# 重载unit配置文件
systemctl daemon-reload
# 启动Docker
systemctl start docker

5,加入开机启动项

## 添加
ln -s /usr/lib/systemd/system/docker.service /etc/systemd/system/multi-user.target.wants/docker.service

## 检查是否加入开机启动项
systemctl list-unit-files|grep docker

6.常见报错说明

(1), 报错1:启动镜像报错

报错原因说明:在Centos中未关闭SeLinux

  • 内容如下:
    docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused "write /proc/self/attr/keycreate: permission denied"": unknown.
  • 解决方法:关闭SeLinux
    • 临时关闭:setenforce 0
    • 永久关闭:把“/etc/selinux/config”里面的SELINUX值修改为disabled,然后保存重启。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容