centos7無網環境安裝docker

1、下載docker的安裝文件

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

由於公司OpenStack用的docker版本是18.09.0

所以,下載的是:docker-18.09.0-ce.tgz 這個壓縮文件

 

 

2、上傳docker-18.09.0-ce.tgz 到系統,用ftp工具上傳即可

 

3、解壓

tar -zxvf docker-18.06.3-ce.tgz

 

4、將解壓出來的docker文件複製到 /usr/bin/ 目錄下

cp docker/* /usr/bin/

 

 5、進入/etc/systemd/system/目錄,並創建docker.service文件

cd /etc/systemd/system/
vi docker.service

 

6、將以下內容複製進去(192.168.100.108改爲你的服務器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.100.108
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

 

7、給docker.service文件添加執行權限

chmod 777 /etc/systemd/system/docker.service 

 

8、重新加載配置文件(每次有修改docker.service文件時都要重新加載下)

systemctl daemon-reload 

 

9、啓動

systemctl start docker

 

10、設置開機啓動

systemctl enable docker.service

 

11、查看docker狀態

systemctl status docker

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

 

 

12、配置鏡像加速器,默認是到國外拉取鏡像速度慢,可以配置國內的鏡像如:阿里、網易等等。

下面配置一下網易的鏡像加速器。打開docker的配置文件: /etc/docker/daemon.json文件:

vi /etc/docker/daemon.json

配置如下:

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

 

13、保存配置並重啓docker 一定要重啓不然加速是不會生效的!!!

service docker restart

 

14、測試docker導入安裝鏡像

h1_01_import_images.sh 

 

 導入鏡像

查看鏡像

 

運行容器並進入

 

 

 OK,到此沒有問題,無網環境安裝docker成功!!

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章