当前位置:   article > 正文

docker离线和在线安装_docker 离线

docker 离线

一.docker环境

1.在线安装

  1. ###########centos在线安装#############
  2. #1.更新yum源
  3. wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  4. yum clean all
  5. yum makecache
  6. #2.添加docker国内镜像源
  7. yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  8. #3.安装docker
  9. yum -y install docker-ce docker-ce-cli containerd.io
  10. ##########ubuntu在线安装#########
  11. apt install -y docker.io

2.离线安装

  1. #1.自己准备docker离线包,本文自带
  2. dockerBin.zip
  3. #2.解压移动文件
  4. unzip dockerBin.zip
  5. cp ./docker/* /usr/bin/ #启动程序
  6. cp ./docker/docker.service /etc/systemd/system #开机自启文件,末尾有,第4小节
  7. #3.启动docker、开机自启、查看docker启动状态
  8. systemctl daemon-reload #重新加载systemctl文件
  9. systemctl start docker && systemctl enable docker && systemctl status docker
  10. #4.docker.service文件如下
  11. cat docker.service
  12. [Unit]
  13. Description=Docker Application Container Engine
  14. Documentation=https://docs.docker.com
  15. # BindsTo=containerd.service
  16. After=network-online.target firewalld.service # containerd.service
  17. Wants=network-online.target
  18. # Requires=docker.socket
  19. [Service]
  20. Type=notify
  21. # the default is not to use systemd for cgroups because the delegate issues still
  22. # exists and systemd currently does not support the cgroup feature set required
  23. # for containers run by docker
  24. EnvironmentFile=-/etc/sysconfig/docker
  25. EnvironmentFile=-/etc/sysconfig/docker-storage
  26. EnvironmentFile=-/etc/sysconfig/docker-network
  27. Environment=GOTRACEBACK=crash
  28. ExecStart=/usr/bin/dockerd $OPTIONS \
  29. $DOCKER_STORAGE_OPTIONS \
  30. $DOCKER_NETWORK_OPTIONS \
  31. $INSECURE_REGISTRY
  32. # -H fd:// --containerd=/run/containerd/containerd.sock
  33. ExecReload=/bin/kill -s HUP $MAINPID
  34. TimeoutSec=0
  35. RestartSec=2
  36. Restart=always
  37. # Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
  38. # Both the old, and new location are accepted by systemd 229 and up, so using the old location
  39. # to make them work for either version of systemd.
  40. StartLimitBurst=3
  41. # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
  42. # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
  43. # this option work for either version of systemd.
  44. StartLimitInterval=60s
  45. # Having non-zero Limit*s causes performance problems due to accounting overhead
  46. # in the kernel. We recommend using cgroups to do container-local accounting.
  47. LimitNOFILE=infinity
  48. LimitNPROC=infinity
  49. LimitCORE=infinity
  50. # Comment TasksMax if your systemd version does not support it.
  51. # Only systemd 226 and above support this option.
  52. TasksMax=infinity
  53. # set delegate yes so that systemd does not reset the cgroups of docker containers
  54. Delegate=yes
  55. # kill only the docker process, not all processes in the cgroup
  56. KillMode=process
  57. [Install]
  58. WantedBy=multi-user.target

3.docker镜像加速配置

  1. #编写/etc/docker/daemon.json配置文件
  2. #1.基础版本,完全够用
  3. tee /etc/docker/daemon.json <<-'EOF'
  4. {
  5. "registry-mirrors": ["https://ej3odski.mirror.aliyuncs.com"]
  6. }
  7. EOF
  8. #2.不理解不要配
  9. tee /etc/docker/daemon.json <<-'EOF'
  10. {
  11. "log-driver": "json-file",
  12. "log-opts": {
  13. "max-size": "100m",
  14. "max-file": "3"
  15. },
  16. "exec-opts": ["native.cgroupdriver=systemd"],
  17. "storage-driver": "overlay2",
  18. "storage-opts": [
  19. "overlay2.override_kernel_check=true"
  20. ],
  21. "registry-mirrors": [
  22. "https://docker.mirrors.ustc.edu.cn",
  23. "https://hub-mirror.c.163.com"
  24. ]
  25. }
  26. EOF
  27. #注意配置文件更新后需要重启docker
  28. systemctl restart docker

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/970516
推荐阅读
相关标签
  

闽ICP备14008679号