欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

docker離線安裝并導(dǎo)入鏡像過程

 更新時間:2023年12月15日 08:39:26   作者:古甲哈醒  
這篇文章主要介紹了docker離線安裝并導(dǎo)入鏡像過程,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

實際項目開發(fā)過程中,客戶環(huán)境大多是全內(nèi)網(wǎng)環(huán)境,無法連接互聯(lián)網(wǎng)。這樣docker就不能yum在線聯(lián)網(wǎng)安裝,所需要的鏡像也不能在線pull下載。這時就需要進(jìn)行離線安裝docker及鏡像。

1、下載docker安裝文件

離線安裝docker,需要下載docker的安裝文件。

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

我下的是最新的版本[docker-19.03.6.tgz],文件不大,只有60M左右。

2、離線docker安裝

將安裝包文件上傳到服務(wù)器目錄并解壓。

[root@iZbp13sno1lc2yxlhjc4b3Z ~]#tar -xvf docker-19.03.6.tar

將解壓出來的docker文件內(nèi)容移動到 /usr/bin/ 目錄下

[root@iZbp13sno1lc2yxlhjc4b3Z ~]#cp docker/* /usr/bin/

將docker注冊為service,在/etc/systemd/system目錄下創(chuàng)建docker.service文件,并配置如下內(nèi)容保存。

[root@iZbp13sno1lc2yxlhjc4b3Z ~]#vim /etc/systemd/system/docker.service
[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
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

添加文件權(quán)限并啟動docker,執(zhí)行如下命令:

chmod +x /etc/systemd/system/docker.service                      #添加文件權(quán)限
systemctl daemon-reload                                                       #重載unit配置文件
systemctl start docker                                                            #啟動Docker
systemctl enable docker.service                                            #設(shè)置開機自啟

驗證docker安裝是否成功:

systemctl status docker                                                         #查看Docker狀態(tài)
docker -v                                                                                #查看Docker版本

Docker離線安裝好后,下面我們把鏡像導(dǎo)入到Docker。

3、離線鏡像文件導(dǎo)入

內(nèi)網(wǎng)環(huán)境沒法pull鏡像,但是docker本身可以將已有的鏡像導(dǎo)出成tar文件,并且可以再次導(dǎo)入到docker,利用這一點,可以實現(xiàn)離線鏡像文件的下載。
 

找一臺可以聯(lián)網(wǎng)的docker機器,并pull下載需要的鏡像文件

然后使用如下命令將鏡像文件導(dǎo)出:

docker save java:8 -o java.tar  #將java 8的鏡像導(dǎo)出成tar文件

將tar文件上傳到內(nèi)網(wǎng)docker服務(wù)器,使用如下命令導(dǎo)入鏡像文件:

docker load -i java.tar

查看導(dǎo)入的鏡像文件:

[root@iZbp13sno1lc2yxlhjc4b3Z ~]# docker images
REPOSITORY                                             TAG                 IMAGE ID            CREATED             SIZE
java                                                   8                   d23bdf5b1b1b        3 years ago         643MB

OK,通過上述方式,實現(xiàn)了內(nèi)網(wǎng)環(huán)境下docker的安裝和鏡像文件下載。后續(xù)我們就可以愉快的使用docker來部署管理我們的應(yīng)用了。

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論