离线安装docker
一、离线下载docker, 选择最新版本的Ce版本就好,
二、 sftp上传到目标服务器(过程略)
三、解压文件
四、复制文件到 /usr/bin
五、配置docker
六、启动Docker
七、验证
离线安装docker
由于网络隔离的原因,部分服务器如数据库服务器没有互联网访问环境,需要离线安装docker.
一、离线下载docker, 选择最新版本的Ce版本就好,
Docker CE是免费的Docker产品的新名称,Docker CE包含了完整的Docker平台,非常适合开发人员和运维团队构建容器APP。
https://download.docker.com/linux/static/stable/x86_64/
二、 sftp上传到目标服务器(过程略)
三、解压文件
tar -zxvf docker-18.06.3-ce.tgz
四、复制文件到 /usr/bin
cp docker/* /usr/bin/
复制到 /usr/bin 相当于配置了path,命令终端里能调用 docker 命令。
五、配置docker
由于是离线安装,所以需要手动添加 docker.service配置文件。
修改一下docker默认镜像和容器在系统中的磁盘目录
注意这一行要改成自己的配置
ExecStart=/usr/bin/dockerd --graph=/MysqlDb/docker --storage-driver=overlay
Docker默认的镜像和容器存储位置在/var/lib/docker中
修改docker.service文件,指定镜像仓库目录
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 --graph=/MysqlDb/docker --storage-driver=overlay --registry-mirror=https://s42tycw4.mirror.aliyuncs.com
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
六、启动Docker
chmod +x /etc/systemd/system/docker.service #添加文件权限并启动docker
systemctl daemon-reload #重载unit配置文件
systemctl start docker #启动Docker
systemctl enable docker.service #设置开机自启
七、验证
systemctl status docker #查看Docker状态
docker -v #查看Docker版本