linux下无网络docker安装及基础镜像制作

一、无网络环境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

以上基础镜像 制作成功。

当你试图去用自己的言语去讲清一些事物时,你会明白对此事物的理解是融会贯通还是一知半解
原文地址:https://www.cnblogs.com/1211-1010/p/12969536.html