Admin

Redhat离线安装Docker
2019年10月25日 17:10 4 0 0 0

下载二进制包

到官网下载对应的Docker二进制压缩包, https://download.docker.com/linux/static/stable/x86_64/
例如,我下载了: docker-18.09.0.tgz

解压并复制(安装)

  1. tar -zxvf docker-18.09.0.tgz
  2. cp docker/* /usr/bin

服务脚本

新建文件 /etc/systemd/system/docker.service,添加如下内容:

  1. [Unit]
  2. Description=Docker Application Container Engine
  3. Documentation=https://docs.docker.com
  4. After=network-online.target firewalld.service
  5. Wants=network-online.target
  6. [Service]
  7. Type=notify
  8. # the default is not to use systemd for cgroups because the delegate issues still
  9. # exists and systemd currently does not support the cgroup feature set required
  10. # for containers run by docker
  11. ExecStart=/usr/bin/dockerd
  12. ExecReload=/bin/kill -s HUP $MAINPID
  13. # Having non-zero Limit*s causes performance problems due to accounting overhead
  14. # in the kernel. We recommend using cgroups to do container-local accounting.
  15. LimitNOFILE=infinity
  16. LimitNPROC=infinity
  17. LimitCORE=infinity
  18. # Uncomment TasksMax if your systemd version supports it.
  19. # Only systemd 226 and above support this version.
  20. #TasksMax=infinity
  21. TimeoutStartSec=0
  22. # set delegate yes so that systemd does not reset the cgroups of docker containers
  23. Delegate=yes
  24. # kill only the docker process, not all processes in the cgroup
  25. KillMode=process
  26. # restart the docker process if it exits prematurely
  27. Restart=on-failure
  28. StartLimitBurst=3
  29. StartLimitInterval=60s
  30. [Install]
  31. WantedBy=multi-user.target

启动 & 开机自动启动

  1. systemctl start docker
  2. systemctl status docker
  3. systemctl enable docker

测试 & 使用

  1. docker ps -a
  2. docker images

参考链接

https://www.cnblogs.com/h-zhang/p/11172970.html

发布内容,请遵守相关法律法规。
评论