京东6.18大促主会场领京享红包更优惠

 找回密码
 立即注册

QQ登录

只需一步,快速开始

docker 安装、升级、修改数据目次的操作方法

2024-11-3 13:51| 发布者: f5db4| 查看: 102| 评论: 0

摘要: 目次1、查察体系要求2、删除旧版本3、安装必要的软件包4、设置Docker yum源5、查察全部堆栈中全部docker版本6、安装docker7、启动8、修改数据目次方式一方式二9、停止docker服务10、修改docker服务启动文件11、复制
目次

1、查察体系要求

Docker 要求 CentOS 体系的内核版本高于 3.10 ,查察CentOS的内核版本。

[code]uname -a[/code]

2、删除旧版本

[code]yum remove docker docker-common docker-selinux docker-engine[/code]

3、安装必要的软件包

yum-util 提供yum-config-manager功能,别的两个是devicemapper驱动依赖的

[code]sudo yum install -y yum-utils device-mapper-persistent-data lvm2[/code]

4、设置Docker yum源

[code]# 使用官方源 sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo # 使用阿里源 sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo[/code]

5、查察全部堆栈中全部docker版本

可以查察全部堆栈中全部docker版本,并选择特定的版本安装。

[code]yum list docker-ce --showduplicates | sort -r[/code]

6、安装docker

sh

[code]sudo yum install docker-ce[/code]

由于repo中默认只开启stable堆栈,故这里安装的是最新稳18.03.0.ce-1.el7.centos。

如果要安装特定版本:

[code]sudo yum install docker-ce-18.06.1.ce[/code]

7、启动

设置为开机启动

[code]systemctl enable docker[/code]

启动

[code]systemctl start docker[/code]

查察启动状态

[code]systemctl status docker[/code]

如果出现非常

[code]$ systemctl start docker A dependency job for docker.service failed. See 'journalctl -xe' for details.[/code]

查察报错信息

[code]Mar 03 11:19:47 master1 systemd[1]: Starting containerd container runtime... -- Subject: Unit containerd.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit containerd.service has begun starting up. Mar 03 11:19:47 master1 systemd[104332]: Failed at step LIMITS spawning /sbin/modprobe: Operation not permitted -- Subject: Process /sbin/modprobe could not be executed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- The process /sbin/modprobe could not be executed and failed. -- -- The error number returned by this process is 1. Mar 03 11:19:47 master1 systemd[104335]: Failed at step LIMITS spawning /usr/bin/containerd: Operation not permitted -- Subject: Process /usr/bin/containerd could not be executed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- The process /usr/bin/containerd could not be executed and failed.[/code]

办理方案:
查察open files的值,修改/usr/lib/systemd/system/docker.service和/usr/lib/systemd/system/containerd.service(如下图),启动即可

[code]$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 23056 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 654350 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 23056 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited[/code] [code]$ vim /usr/lib/systemd/system/docker.service ... # 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=654349 # 留意这里 LimitNPROC=23057 LimitCORE=infinity # Comment TasksMax if your systemd version does not supports it. ...[/code] [code]$ vim /usr/lib/systemd/system/containerd.service ... # 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=654349 # 留意这里 LimitNPROC=23057 LimitCORE=infinity # Comment TasksMax if your systemd version does not support it. ...[/code]

查察版本

[code]docker version[/code]

8、修改数据目次

方式一

[code]# 将下面的json拷贝纸docker启动目次 $ vim /etc/docker/daemon.json { "data-root": "/data/docker" }[/code]

方式二

查察docker当前信息

[code]$ docker info Client: Context: default Debug Mode: false Plugins: app: Docker App (Docker Inc., v0.9.1-beta3) buildx: Docker Buildx (Docker Inc., v0.8.2-docker) scan: Docker Scan (Docker Inc., v0.17.0) Server: Containers: 40 Running: 15 Paused: 0 Stopped: 25 Images: 91 Server Version: 20.10.17 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: systemd Cgroup Version: 1 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: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc Default Runtime: runc Init Binary: docker-init containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1 runc version: v1.1.2-0-ga916309f init version: de40ad0 Security Options: seccomp Profile: default Kernel Version: 3.10.0-1160.71.1.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 16 Total Memory: 15.5GiB Name: master1 ID: 3WQC:QCTB:I5D4:2ZWL:VBSH:6GWQ:4W2G:BTK2:XSEY:PDXG:BQAI:ZB6D Docker Root Dir: /data/docker # 这里是数据目次的位置,我由于已经更改过,原位置为/var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Registry Mirrors: https://x6u7jv2l.mirror.aliyuncs.com/ Live Restore Enabled: false[/code]

9、停止docker服务

[code]$ systemctl stop docker[/code]

10、修改docker服务启动文件

[code]vi /usr/lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --graph=/data/docker[/code]

11、复制原有数据,若无数据,可跳过此步骤

[code]$ cp -rf /var/lib/docker/* /data/docker/[/code]

12、重新加载设置文件并启动

[code]$ systemctl daemon-reload $ systemctl start docker[/code]

最后执行步骤8,查察是否已启动

到此这篇关于docker 安装、升级、修改数据目次的操作方法的文章就介绍到这了,更多相关docker 修改数据目次内容请搜刮脚本之家以前的文章或继承欣赏下面的相关文章渴望各人以后多多支持脚本之家!


来源:https://www.jb51.net/server/3262162uf.htm
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
关闭

站长推荐上一条 /6 下一条

QQ|手机版|小黑屋|梦想之都-俊月星空 ( 粤ICP备18056059号 )|网站地图

GMT+8, 2025-7-1 18:38 , Processed in 0.037050 second(s), 18 queries .

Powered by Mxzdjyxk! X3.5

© 2001-2025 Discuz! Team.

返回顶部