centos7-linux安裝docker(離線方式)


  1. 下載docker的安裝文件

https://download.docker.com/linux/static/stable/x86_64/

下載的是:docker-18.06.3-ce.tgz 這個壓縮文件

  1. 將docker-18.06.3-ce.tgz文件上傳到centos7-linux系統上,用ftp工具上傳即可

  1. 解壓
[root@localhost java]# tar -zxvf docker-18.06.3-ce.tgz
  1. 將解壓出來的docker文件復制到 /usr/bin/ 目錄下
[root@localhost java]# cp docker/* /usr/bin/
  1. 進入/etc/systemd/system/目錄,並創建docker.service文件
[root@localhost java]# cd /etc/systemd/system/
[root@localhost system]# touch docker.service
  1. 打開docker.service文件,將以下內容復制
[root@localhost system]# vi docker.service

注意: --insecure-registry=192.168.200.128 此處改為你自己服務器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.200.128
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

  1. 給docker.service文件添加執行權限
[root@localhost system]# chmod 777 /etc/systemd/system/docker.service 
  1. 重新加載配置文件(每次有修改docker.service文件時都要重新加載下)
[root@localhost system]# systemctl daemon-reload 
  1. 啟動
[root@localhost system]# systemctl start docker
  1. 設置開機啟動
[root@localhost system]# systemctl enable docker.service
  1. 查看docker狀態
[root@localhost system]# systemctl status docker

出現下面這個界面就代表docker安裝成功。

  1. 配置鏡像加速器,默認是到國外拉取鏡像速度慢,可以配置國內的鏡像如:阿里、網易等等。下面配置一下網易的鏡像加速器。打開docker的配置文件: /etc/docker/daemon.json文件:
[root@localhost docker]# vi /etc/docker/daemon.json

配置如下:

{"registry-mirrors": ["http://hub-mirror.c.163.com"]}

配置完后:wq保存配置並重啟docker 一定要重啟不然加速是不會生效的!!!

[root@localhost docker]# service docker restart

參考:https://www.cnblogs.com/kingsonfu/p/11576797.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM