`

Centos7离线安装Docker

阅读更多

下载Docker并安装

docker包下载地址

  1. #下载docker-20.10.0包
  2. https://download.docker.com/linux/static/stable/x86_64/docker-20.10.0.tgz
  3. #上传到Centos系统/data/目录,如
  4. scp docker-20.10.0.tgz root@192.168.0.5:/data/
  5. #进入data目录,解压docker包
  6. cd /data
  7. tar -zxvf docker-20.10.0.tgz
  8. #将解压出来的docker文件内容移动到 /usr/bin/ 目录下
  9. cp docker/* /usr/bin/
  10. #查看docker版本
  11. docker version
  12. #查看docker信息
  13. docker info

配置Docker开机自启动服务

  1. #添加docker.service文件
  2. vi /etc/systemd/system/docker.service
  3. #按i插入模式,复制如下内容:
  1. [Unit]
  2. Description=DockerApplicationContainerEngine
  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. #添加文件可执行权限
  2. chmod +x /etc/systemd/system/docker.service
  3. #重新加载配置文件
  4. systemctl daemon-reload
  5. #启动Docker
  6. systemctl start docker
  7. #查看docker启动状态
  8. systemctl status docker
  9. #查看启动容器
  10. docker ps
  11. #设置开机自启动
  12. systemctl enable docker.service
  13. #查看docker开机启动状态 enabled:开启, disabled:关闭
  14. systemctl is-enabled docker.service
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics