CentOS 7 离线安装Docker

2023-12-13 05:48:55

解压

cd /data/tools

rz docker-24.0.6.tgz docker-compose-linux-x86_64

mkdir docker-24.0.6
tar -zxvf docker-24.0.6.tgz -C docker-24.0.6
sudo cp -r docker-24.0.6/docker/* /usr/bin/

注册服务

vim /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=100m
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target

## 重新加载
systemctl daemon-reload

修改存储目录

mkdir /etc/docker

vim /etc/docker/daemon.json

{
  "data-root": "/data/docker/root_dir/"
}

启动

# 启动
systemctl start docker
# 设置开机自启
systemctl enable docker.service

# 没有镜像,离线无法测试安装,需要手动导入镜像测试
docker run hello-world

查看docker版本
docker version

安装docker-compose

# 1.将安装文件复制到/usr/local/bin/目录下
cp docker-compose-linux-x86_64 /usr/local/bin/docker-compose
 
# 2.将该文件赋为可执行文件
chmod +x /usr/local/bin/docker-compose
 
# 3.创建软链
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
 
# 4.测试是否安装成功
docker-compose -version

参考

https://www.cnblogs.com/astonc/p/17307333.html

https://blog.csdn.net/carefree2005/article/details/130616307
https://blog.csdn.net/weixin_39651041/article/details/130916908

文章来源:https://blog.csdn.net/z1353095373/article/details/134372184
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。