Linux服务器下docker环境离线部署安装

环境清理(卸载旧版本 Docker)

如果之前没有安装过,可跳过这一步。

 #sudo yum remove docker \
 	docker-client \
 	docker-client-latest \
 	docker-common \
 	docker-latest \
 	docker-latest-logrotate \
 	docker-logrotate \
 	docker-selinux \
 	docker-engine-selinux \
 	docker-engine
# rm -rf /etc/systemd/system/docker.service.d
# rm -rf /var/lib/docker
# rm -rf /var/run/docker

安装 Docker

此次部署的docker版本为 docker-ce-19.03.9
(需要安装包的可以关注后私信我)

获取docker的rpm包

[root@VM-4-16-centos docker_softwarepackage]# pwd
/data/docker_softwarepackage
[root@VM-4-16-centos docker_softwarepackage]# ll
total 89960
-rw-r--r-- 1 root root 26675948 Sep  7 14:28 containerd.io-1.2.13-3.2.el7.x86_64.rpm
-rw-r--r-- 1 root root    40664 Sep  7 14:28 container-selinux-2.119.1-1.c57a6f9.el7.noarch.rpm
-rw-r--r-- 1 root root 25286180 Sep  7 14:28 docker-ce-19.03.9-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 40047696 Sep  7 14:28 docker-ce-cli-19.03.9-3.el7.x86_64.rpm
-rw-r--r-- 1 root root    57460 Sep  7 14:28 libseccomp-2.3.1-4.el7.x86_64.rpm
[root@VM-4-16-centos docker_softwarepackage]#

批量安装rpm包

[root@VM-4-16-centos docker_softwarepackage]# ls
containerd.io-1.2.13-3.2.el7.x86_64.rpm             docker-ce-19.03.9-3.el7.x86_64.rpm      libseccomp-2.3.1-4.el7.x86_64.rpm
container-selinux-2.119.1-1.c57a6f9.el7.noarch.rpm  docker-ce-cli-19.03.9-3.el7.x86_64.rpm
[root@VM-4-16-centos docker_softwarepackage]#  rpm -Uvh *.rpm --nodeps --force
warning: containerd.io-1.2.13-3.2.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:libseccomp-2.3.1-4.el7           ################################# [ 20%]
   2:container-selinux-2:2.119.1-1.c57################################# [ 40%]
setsebool:  SELinux is disabled.

   3:containerd.io-1.2.13-3.2.el7     ################################# [ 60%]
   4:docker-ce-cli-1:19.03.9-3.el7    ################################# [ 80%]
   5:docker-ce-3:19.03.9-3.el7        ################################# [100%]
[root@VM-4-16-centos docker_softwarepackage]#

启动 docker

[root@VM-4-16-centos docker_softwarepackage]# systemctl start docker
[root@VM-4-16-centos docker_softwarepackage]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2023-09-07 14:37:36 CST; 11s ago
     Docs: https://docs.docker.com
 Main PID: 16867 (dockerd)
    Tasks: 9
   Memory: 37.9M
   CGroup: /system.slice/docker.service
           └─16867 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.042045090+08:00" level=info msg="scheme \"unix\" not registered, fallback to default s...odule=grpc
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.042058960+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///r...odule=grpc
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.042067410+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.109099201+08:00" level=info msg="Loading containers: start."
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.238905230+08:00" level=info msg="Default bridge (docker0) is assigned with an IP addre...P address"
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.291912500+08:00" level=info msg="Loading containers: done."
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.323120612+08:00" level=info msg="Docker daemon" commit=9d988398e7 graphdriver(s)=overl...on=19.03.9
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.323235540+08:00" level=info msg="Daemon has completed initialization"
Sep 07 14:37:36 VM-4-16-centos systemd[1]: Started Docker Application Container Engine.
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.364521197+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
[root@VM-4-16-centos docker_softwarepackage]#

docker数据目录更改

1、查看当前docker的数据目录

[root@VM-4-16-centos docker_softwarepackage]# docker info
Client:
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 19.03.9
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-1160.88.1.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 1.952GiB
 Name: VM-4-16-centos
 ID: 5FXK:HWAX:M5S4:MGOZ:RVAC:OSOW:BE7T:2EF6:KEGA:COEC:6YJA:SJ74
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
[root@VM-4-16-centos docker_softwarepackage]#

可以看到当前的docker数据目录为

Docker Root Dir: /var/lib/docker

2、停止 docker

[root@VM-4-16-centos docker_softwarepackage]# systemctl stop docker
[root@VM-4-16-centos docker_softwarepackage]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.docker.com

Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.238905230+08:00" level=info msg="Default bridge (docker0) is assigned with an IP addre...P address"
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.291912500+08:00" level=info msg="Loading containers: done."
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.323120612+08:00" level=info msg="Docker daemon" commit=9d988398e7 graphdriver(s)=overl...on=19.03.9
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.323235540+08:00" level=info msg="Daemon has completed initialization"
Sep 07 14:37:36 VM-4-16-centos systemd[1]: Started Docker Application Container Engine.
Sep 07 14:37:36 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:37:36.364521197+08:00" level=info msg="API listen on /var/run/docker.sock"
Sep 07 14:44:59 VM-4-16-centos systemd[1]: Stopping Docker Application Container Engine...
Sep 07 14:44:59 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:44:59.934711435+08:00" level=info msg="Processing signal 'terminated'"
Sep 07 14:44:59 VM-4-16-centos dockerd[16867]: time="2023-09-07T14:44:59.935349640+08:00" level=info msg="Daemon shutdown complete"
Sep 07 14:44:59 VM-4-16-centos systemd[1]: Stopped Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[root@VM-4-16-centos docker_softwarepackage]#

3、修改数据目录配置

[root@VM-4-16-centos data]# mkdir docker_data
[root@VM-4-16-centos data]# cd docker_data/
[root@VM-4-16-centos docker_data]# pwd
/data/docker_data
[root@VM-4-16-centos docker_data]#  vi /usr/lib/systemd/system/docker.service
# 增加数据目录配置:--graph=/data/docker_data

在这里插入图片描述

[root@VM-4-16-centos docker_data]# systemctl daemon-reload        # 重新加载配置
[root@VM-4-16-centos docker_data]# systemctl restart docker       # 重启 docker
[root@VM-4-16-centos docker_data]# systemctl enable docker		  # 设置开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@VM-4-16-centos docker_data]#
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值