一、無網絡環境docker安裝
有網絡時docker安裝非常方便,使用yum命令進行安裝即可。沒網絡該咋樣安裝docker呢?下面將無網絡環境docker安裝過程做一記錄。、
下面安裝過程是在rhel7.7系統上進行的。
1.安裝依賴包:yum install -y yum-utils device-mapper-persistent-data lvm2
2..首先需要下載好docker的二進制安裝文件壓縮包,地址:https://download.docker.com/linux/static/stable/
根據自己的平台下載相應的壓縮包,版本自己選擇,我這里下載的是:docker-17.03.0-ce.tgz。
2.拷貝tar到機器中解壓:tar -xzvf docker-17.03.0-ce.tgz
3.將解壓的文件拷貝到/usr/bin/目錄下:cp docker/* /usr/bin/
4.創建docker.service。
在/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
5.賦權:chmod +x /etc/systemd/system/docker.service
6.使配置生效、啟動docker服務並查看服務狀態:systemctl daemon-reload systemctl start docker.service systemctl status docker.service
7. 設置服務自啟動:systemctl enable docker.service
8.檢查docker安裝是否成功:docker info
如圖出現上述docker信息證明安裝完成。
二、以自己現在的環境為准制作自己的docker基礎鏡像:
1.將環境打包:
tar --numeric-owner --exclude=/proc --exclude=/sys -cvf rhel7.7_base.tar /
2.將制作的鏡像導入並命名:
cat rhel7.7_base.tar | docker import - rhel7.7_mini
3.查詢鏡像docker images
以上基礎鏡像 制作成功。