Linux离线安装Docker
编辑前提情况
因为网络或者其他原因,不能在线部署,这时候就需要以离线的方式安装Docker
Docker安装
获取docker安装文件,官方地址如下:
https://download.docker.com/linux/static/stable/x86_64/docker-19.03.9.tgz
将下载的安装文件进行解压:
tar zxvf docker-19.03.9.tgz
将解压后文件全部移动/usr/bin目录
cp -p docker/* /usr/bin
将Dockers注册为服务
创建服务文件
vi /usr/lib/systemd/system/docker.service
文件内容
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
WorkingDirectory=/usr/local/bin
ExecStart=/usr/bin/dockerd \
-H tcp://0.0.0.0:4243 \
-H unix:///var/run/docker.sock \
--selinux-enabled=false \
--log-opt max-size=1g
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=on-failure
[Install]
WantedBy=multi-user.target
重新加载Docker配置文件,命令如下:
systemctl daemon-reload
启动docker,命令如下:
systemctl start docker
设置docker开机启动,命令如下:
systemctl enable docker
查看docker是否安装成功,命令如下:
docker version
Docker-Compose安装
获取docker-compose部署文件,官方获取地址如下:
https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-linux-x86_64
将上述文件拷贝至服务器某处,然后将其移动到/usr/local/bin,并重命名为“docker-compose”,命令如下:
mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
为docker-compose文件赋予可执行权限,命令如下:
chmod +x /usr/local/bin/docker-compose
查看是否安装成功,命令如下:
docker-compose -v
- 157
-
分享