首页 > 其他分享 >​​统信UOS服务器操作系统迁移docker目录​​

​​统信UOS服务器操作系统迁移docker目录​​

时间:2023-06-26 20:08:13浏览次数:37  
标签:UOS 20 uel20 nginx 统信 docker root localhost

原文链接:统信UOS服务器操作系统迁移docker目录

hello,大家好啊,今天给大家带来一篇在统信UOS服务器操作系统上迁移docker目录的文章,在工作中我们会发现,当我们没有将/var目录单独分区的时候,运行docker容器后,会将根目录挤压,因此我们可以通过迁移docker目录的方式,释放根路径的磁盘空间,文章内容仅供参考,生产环境请根据实际情况调整,话不多说,让我们开始吧。

1、查看系统版本


[root@localhost ~]# cat /etc/os-version           
[Version]           
SystemName=UnionTech OS Server          
SystemName[zh_CN]=统信服务器操作系统          
ProductType=Server          
ProductType[zh_CN]=服务器          
EditionName=e          
EditionName[zh_CN]=e          
MajorVersion=20          
MinorVersion=1050          
OsBuild=12038.101          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_nginx

         

         

2、安装docker-ce


[root@localhost ~]# yum install docker-ce -y          
Last metadata expiration check: 0:00:46 ago on 2023年06月20日 星期二 14时48分41秒.          
Dependencies resolved.          
===================================================================================          
 Package                        Arch        Version                Repo       Size          
===================================================================================          
Installing:          
 docker-ce                      x86_64      20.10.7-3.uel20        repo       23 M          
Installing dependencies:          
 container-selinux              noarch      2:2.138.0-1.uel20      repo       36 k          
 containerd.io                  x86_64      1.5.5-1.uel20          repo       35 M          
 docker-ce-cli                  x86_64      20.10.7-3.uel20        repo       30 M          
 docker-ce-rootless-extras      x86_64      20.10.7-3.uel20        repo      4.5 M          
 docker-scan-plugin             x86_64      0.7.0-3.uel20          repo      3.7 M          
 libcgroup                      x86_64      0.42.2-3.uel20         repo       95 k          




          
Transaction Summary          
===================================================================================          
Install  7 Packages          




          
Total size: 96 M          
Installed size: 400 M          
Downloading Packages:          
Running transaction check          
Transaction check succeeded.          
Running transaction test          
Transaction test succeeded.          
Running transaction          
  Preparing        :                                                           1/1           
  Installing       : docker-scan-plugin-0.7.0-3.uel20.x86_64                   1/7           
  Installing       : docker-ce-cli-20.10.7-3.uel20.x86_64                      2/7           
  Running scriptlet: docker-ce-cli-20.10.7-3.uel20.x86_64                      2/7           
  Running scriptlet: libcgroup-0.42.2-3.uel20.x86_64                           3/7           
  Installing       : libcgroup-0.42.2-3.uel20.x86_64                           3/7           
  Running scriptlet: libcgroup-0.42.2-3.uel20.x86_64                           3/7           
  Installing       : docker-ce-rootless-extras-20.10.7-3.uel20.x86_64          4/7           
  Installing       : containerd.io-1.5.5-1.uel20.x86_64                        5/7           
  Running scriptlet: containerd.io-1.5.5-1.uel20.x86_64                        5/7           
  Installing       : container-selinux-2:2.138.0-1.uel20.noarch                6/7           
  Running scriptlet: container-selinux-2:2.138.0-1.uel20.noarch                6/7           
Deprecated, use selabel_lookup          




          
  Installing       : docker-ce-20.10.7-3.uel20.x86_64                          7/7           
  Running scriptlet: docker-ce-20.10.7-3.uel20.x86_64                          7/7           
  Verifying        : container-selinux-2:2.138.0-1.uel20.noarch                1/7           
  Verifying        : containerd.io-1.5.5-1.uel20.x86_64                        2/7           
  Verifying        : docker-ce-20.10.7-3.uel20.x86_64                          3/7           
  Verifying        : docker-ce-cli-20.10.7-3.uel20.x86_64                      4/7           
  Verifying        : docker-ce-rootless-extras-20.10.7-3.uel20.x86_64          5/7           
  Verifying        : docker-scan-plugin-0.7.0-3.uel20.x86_64                   6/7           
  Verifying        : libcgroup-0.42.2-3.uel20.x86_64                           7/7           




          
Installed:          
  container-selinux-2:2.138.0-1.uel20.noarch                                                 
  containerd.io-1.5.5-1.uel20.x86_64                                                         
  docker-ce-20.10.7-3.uel20.x86_64                                                           
  docker-ce-cli-20.10.7-3.uel20.x86_64                                                       
  docker-ce-rootless-extras-20.10.7-3.uel20.x86_64                                           
  docker-scan-plugin-0.7.0-3.uel20.x86_64                                                    
  libcgroup-0.42.2-3.uel20.x86_64                                                            




          
Complete!

​​统信UOS服务器操作系统迁移docker目录​​_Linux_02

         

         

3、启动docker查看状态


[root@localhost ~]# systemctl start docker          
[root@localhost ~]# systemctl status docker          
● docker.service - Docker Application Container Engine          
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset>          
   Active: active (running) since Tue 2023-06-20 14:51:27 CST; 3s ago          
     Docs: https://docs.docker.com          
 Main PID: 36834 (dockerd)          
    Tasks: 10          
   Memory: 44.0M          
   CGroup: /system.slice/docker.service          
           └─36834 /usr/bin/dockerd -H fd:// --cnotallow=/run/containerd/containe>          




          
6月 20 14:51:26 localhost.localdomain dockerd[36834]: time="2023-06-20T14:51:26.51>          
6月 20 14:51:26 localhost.localdomain dockerd[36834]: time="2023-06-20T14:51:26.51>          
6月 20 14:51:26 localhost.localdomain dockerd[36834]: time="2023-06-20T14:51:26.57>          
6月 20 14:51:27 localhost.localdomain dockerd[36834]: time="2023-06-20T14:51:27.22>          
6月 20 14:51:27 localhost.localdomain dockerd[36834]: time="2023-06-20T14:51:27.35>          
6月 20 14:51:27 localhost.localdomain dockerd[36834]: time="2023-06-20T14:51:27.53>          
6月 20 14:51:27 localhost.localdomain dockerd[36834]: time="2023-06-20T14:51:27.58>          
6月 20 14:51:27 localhost.localdomain dockerd[36834]: time="2023-06-20T14:51:27.58>          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_uos_03

         

         

         

4、配置阿里云docker镜像加速器


[root@localhost ~]# mkdir -p /etc/docker          
[root@localhost ~]# tee /etc/docker/daemon.json <<-'EOF'          
> {          
>   "registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]          
> }          
> EOF          
{          
  "registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]          
}          
[root@localhost ~]# systemctl daemon-reload          
[root@localhost ~]# systemctl restart docker          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_uos_04

         

         

         

         

5、拉取nginx镜像


[root@localhost ~]# docker pull nginx          
Using default tag: latest          
latest: Pulling from library/nginx          
a2abf6c4d29d: Pull complete           
a9edb18cadd1: Pull complete           
589b7251471a: Pull complete           
186b1aaa4aa6: Pull complete           
b4df32aa5a72: Pull complete           
a0bcbecc962e: Pull complete           
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31          
Status: Downloaded newer image for nginx:latest          
docker.io/library/nginx:latest          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_uos_05

         

         

6、查看nginx镜像


[root@localhost ~]# docker images          
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE          
nginx        latest    605c77e624dd   17 months ago   141MB          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_nginx_06

         

         

7、启动nginx


[root@localhost ~]# docker run -d --name nginx -p 80:80 nginx          
dcb11489260306d89e54608e0de1cc7efcce6c444b7f9c85b4018c3bef08a783          
[root@localhost ~]# docker ps          
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                               NAMES          
dcb114892603   nginx     "/docker-entrypoint.…"   4 seconds ago   Up 3 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   nginx          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_docker_07

         

         

8、访问nginx网站,可以看到网站访问成功


[root@localhost ~]# curl http://192.168.122.236          
          
          
          
               
          
          
          


Welcome to nginx!
        
        
If you see this page, the nginx web server is successfully installed and            
working. Further configuration is required.
        




        
        For online documentation and support please refer to            
nginx.org.            
            
Commercial support is available at            
nginx.com.        




        
        Thank you for using nginx.        
        
        
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_deepin_08

         

         

9、停止docker服务


[root@localhost ~]# systemctl stop docker          
Warning: Stopping docker.service, but it can still be activated by:          
  docker.socket          
[root@localhost ~]# systemctl stop docker.socket           
[root@localhost ~]# systemctl status docker          
● docker.service - Docker Application Container Engine          
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset>          
   Active: inactive (dead)          
     Docs: https://docs.docker.com          




          
6月 20 14:59:15 localhost.localdomain dockerd[37327]: time="2023-06-20T14:59:15.26>          
6月 20 14:59:15 localhost.localdomain systemd[1]: Started Docker Application Conta>          
6月 20 14:59:15 localhost.localdomain dockerd[37327]: time="2023-06-20T14:59:15.30>          
6月 20 15:03:52 localhost.localdomain systemd[1]: Stopping Docker Application Cont>          
6月 20 15:03:52 localhost.localdomain dockerd[37327]: time="2023-06-20T15:03:52.29>          
6月 20 15:03:52 localhost.localdomain dockerd[37327]: time="2023-06-20T15:03:52.52>          
6月 20 15:03:52 localhost.localdomain dockerd[37327]: time="2023-06-20T15:03:52.91>          
6月 20 15:03:52 localhost.localdomain dockerd[37327]: time="2023-06-20T15:03:52.91>          
6月 20 15:03:52 localhost.localdomain systemd[1]: docker.service: Succeeded.          
6月 20 15:03:52 localhost.localdomain systemd[1]: Stopped Docker Application Conta>          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_uos_09

         

         

10、同步/var/lib/docker/目录到/home/docker


[root@localhost ~]# rsync -aP /var/lib/docker/ /home/docker/          
runtimes/          
swarm/          
tmp/          
trust/          
volumes/          
volumes/backingFsBlockDev          
volumes/metadata.db          
         32,768 100%   41.29kB/s    0:00:00 (xfr#4432, to-chk=0/6359)

​​统信UOS服务器操作系统迁移docker目录​​_Linux_10

         

         

         

11、重新编辑docker服务配置文件


[root@localhost ~]# cp /usr/lib/systemd/system/docker.service /usr/lib/systemd/system/docker.service.bak          
[root@localhost ~]# vi /usr/lib/systemd/system/docker.service          
[root@localhost ~]# cat /usr/lib/systemd/system/docker.service          
[Unit]          
Description=Docker Application Container Engine          
mentation=https://docs.docker.com          
After=network-online.target firewalld.service containerd.service          
Wants=network-online.target          
Requires=docker.socket containerd.service          




          
[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 --data-root /home/docker          
ExecReload=/bin/kill -s HUP $MAINPID          
TimeoutSec=0          
RestartSec=2          
Restart=always          




          
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.          
# Both the old, and new location are accepted by systemd 229 and up, so using the old location          
# to make them work for either version of systemd.          
StartLimitBurst=3          




          
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.          
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make          
# this option work for either version of systemd.          
StartLimitInterval=60s          




          
# 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          




          
# Comment TasksMax if your systemd version does not support it.          
# Only systemd 226 and above support this option.          
TasksMax=infinity          




          
# 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          
OOMScoreAdjust=-500          




          
[Install]          
WantedBy=multi-user.target

​​统信UOS服务器操作系统迁移docker目录​​_deepin_11

         

​​统信UOS服务器操作系统迁移docker目录​​_docker_12

         

         

         

12、重新启动docker服务


[root@localhost ~]# systemctl daemon-reload           
[root@localhost ~]# systemctl restart docker          
[root@localhost ~]# systemctl status docker          
● docker.service - Docker Application Container Engine          
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset>          
   Active: active (running) since Tue 2023-06-20 15:10:20 CST; 5s ago          
     Docs: https://docs.docker.com          
 Main PID: 38374 (dockerd)          
    Tasks: 9          
   Memory: 44.1M          
   CGroup: /system.slice/docker.service          
           └─38374 /usr/bin/dockerd --data-root /home/docker          




          
6月 20 15:10:19 localhost.localdomain dockerd[38374]: time="2023-06-20T15:10:19.38>          
6月 20 15:10:19 localhost.localdomain dockerd[38374]: time="2023-06-20T15:10:19.63>          
6月 20 15:10:19 localhost.localdomain dockerd[38374]: time="2023-06-20T15:10:19.67>          
6月 20 15:10:19 localhost.localdomain dockerd[38374]: time="2023-06-20T15:10:19.94>          
6月 20 15:10:20 localhost.localdomain dockerd[38374]: time="2023-06-20T15:10:20.05>          
6月 20 15:10:20 localhost.localdomain dockerd[38374]: time="2023-06-20T15:10:20.19>          
6月 20 15:10:20 localhost.localdomain dockerd[38374]: time="2023-06-20T15:10:20.21>          
6月 20 15:10:20 localhost.localdomain dockerd[38374]: time="2023-06-20T15:10:20.21>          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_Linux_13

         

         

13、查看docker是否启用新的数据目录


[root@localhost ~]# docker info |grep "Docker Root Dir"          
 Docker Root Dir: /home/docker          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_Linux_14

         

         

14、查看并清除历史的docker容器


[root@localhost ~]# docker ps -a          
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                     PORTS     NAMES          
dcb114892603   nginx     "/docker-entrypoint.…"   10 minutes ago   Exited (0) 8 minutes ago             nginx          
[root@localhost ~]# docker rm nginx           
nginx

​​统信UOS服务器操作系统迁移docker目录​​_Linux_15

         

         

15、重新启动nginx容器


[root@localhost ~]# docker run -d --name nginx -p 80:80 nginx          
e7f77c08ed3705dabe8a4c8a21ab71f754ee8c5792aef139a7f089e12235c5c2          
[root@localhost ~]# docker ps           
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                               NAMES          
e7f77c08ed37   nginx     "/docker-entrypoint.…"   6 seconds ago   Up 5 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   nginx          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_nginx_16

         

         

16、访问nginx网站,发现访问正常


[root@localhost ~]# curl http://192.168.122.236          
          
          
          
               
          
          
          


Welcome to nginx!
        
        
If you see this page, the nginx web server is successfully installed and            
working. Further configuration is required.
        




        
        For online documentation and support please refer to            
nginx.org.            
            
Commercial support is available at            
nginx.com.        




        
        Thank you for using nginx.        
        
        
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_docker_17

         

         

17、查看磁盘空间,docker数据在/home/docker下


[root@localhost ~]# df -h          
文件系统              容量  已用  可用 已用% 挂载点          
devtmpfs              1.7G     0  1.7G    0% /dev          
tmpfs                 1.7G     0  1.7G    0% /dev/shm          
tmpfs                 1.7G  9.1M  1.7G    1% /run          
tmpfs                 1.7G     0  1.7G    0% /sys/fs/cgroup          
/dev/mapper/uos-root   70G  8.9G   62G   13% /          
tmpfs                 1.7G   28K  1.7G    1% /tmp          
/dev/mapper/uos-home  125G  1.1G  124G    1% /home          
/dev/sda1            1014M  191M  824M   19% /boot          
tmpfs                 343M   56K  343M    1% /run/user/0          
/dev/loop0            522M  522M     0  100% /mnt          
overlay               125G  1.1G  124G    1% /home/docker/overlay2/a1280bbc74922071fe57357fd7dc667e6821ca86ddce4edbb2b4619861cceae2/merged          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_nginx_18

         

         

         

18、删除原有的/var/lib/docker目录,查看释放的磁盘空间大小


[root@localhost ~]# rm -rf /var/lib/docker          
[root@localhost ~]# df -h          
文件系统              容量  已用  可用 已用% 挂载点          
devtmpfs              1.7G     0  1.7G    0% /dev          
tmpfs                 1.7G     0  1.7G    0% /dev/shm          
tmpfs                 1.7G  9.1M  1.7G    1% /run          
tmpfs                 1.7G     0  1.7G    0% /sys/fs/cgroup          
/dev/mapper/uos-root   70G  8.7G   62G   13% /          
tmpfs                 1.7G   28K  1.7G    1% /tmp          
/dev/mapper/uos-home  125G  1.1G  124G    1% /home          
/dev/sda1            1014M  191M  824M   19% /boot          
tmpfs                 343M   56K  343M    1% /run/user/0          
/dev/loop0            522M  522M     0  100% /mnt          
overlay               125G  1.1G  124G    1% /home/docker/overlay2/a1280bbc74922071fe57357fd7dc667e6821ca86ddce4edbb2b4619861cceae2/merged          
[root@localhost ~]#

​​统信UOS服务器操作系统迁移docker目录​​_nginx_19

标签:UOS,20,uel20,nginx,统信,docker,root,localhost
From: https://blog.51cto.com/pengds/6557251

相关文章

  • .NETCore项目在Windows下构建Docker镜像并本地导出分发到CentOS系统下
    在Windows下使用Docker,我们选择DockerDesktop这个软件,非常方便。DockerDesktop介绍及安装DockerDesktop是适用于Mac、Linux或Windows环境的一键安装应用程序,使您能够构建和共享容器化应用程序和微服务。它提供了一个简单的GUI(图形用户界面),允许您直接从机器管理容器、应用程......
  • docker常用命令
    Docker常用命令1.搜索dockersearchmysql2.拉取镜像dockerpullmysql:5.7docker-hub官方:https://hub.docker.com/搜索mysql-tag,复制拉取命令以下载mysql5.7版本为例3.查看镜像和镜像IDdockerimages4.删除镜像dockerrmiimageid5.运行镜像dockerrunimageid--name:容器名称(......
  • linux下docker安装与使用
    linux下docker安装1.安装依赖包执行命令:yuminstall-yyum-utilsdevice-mapper-persistent-datalvm22.安装docker执行命令:yuminstall-ydocker3.启动和关闭docker启动:systemctlstartdocker关闭:systemctlstopdocker......
  • 基于docker部署mysql
    Docker中部署mysql一、给docker创建网络dockernetworkcreate-dbridgemtx二、在任意目录创建mysql配置文件1.创建目录cd到root目录mkdirdockercddockermkdirmysqlcdmysqlmkdirconfcdconftouchmy.cnfcdmysqlmkdirdata2.给mysql配置文件my.cnf添加配置vimy.cnf[mysql......
  • docker-compose管理容器
    docker-compose管理容器一、下载docker-compose1.下载依赖执行命令:curl-Lhttps://get.daocloud.io/docker/compose/releases/download/1.26.2/docker-compose-`uname-s`-`uname-m`>/usr/local/bin/docker-compose2.给下载目录授予权限chomod777/usr/local/bin/docker-com......
  • 基于docker部署tomcat
    基于docker部署tomcat1.下载tomcat容器到docker-hub中去寻找tomcat8的版本,且支持jdk8的版本dockerpulltomcat:8.5.0-jre82.创建映射文件地址cd/root/dockermkdirtomcatmkdirwebapps3.把pinter.db项目放到webapps里,并解压4.修改application.properties配置文件中数据库和red......
  • 基于docker部署redis
    Docker中部署redis一、在docker中拉去redis镜像dockerpullredis二、在本机给redis创建配置文件1.mkdir–p/root/docker/redis/conf2.上传redis自带的redis.conf到改目录下。注意:有可能xftp无法链接,可以先传到其他目录,在linux中移动到该目录3.编辑redis.conf配置文件3.1.把bind......
  • 基于docker部署nginx
    基于docker部署nginx1.拉取nginx镜像文件dockerpullnginx2.创建nginx本地映射文件mkdir-p/root/docker/nginx/logsmkdir-p/root/docker/nginx/conf.dtouchpinter.confvipinter.conf把pinter改为docker中的别名3.启动nginx服务dockerrun-d-p80:80--networkmtx-v/ro......
  • Docker 中的 .NET 异常了怎么抓 Dump
    一:背景1.讲故事有很多朋友跟我说,在Windows上看过你文章知道了怎么抓Crash,CPU爆高,内存暴涨等各种Dump,为什么你没有写在Docker中如何抓的相关文章呢?瞧不上吗?哈哈,在DUMP的分析旅程中,跑在Docker中的.NET占比真的不多,大概10个dump有1-2个是docker中的,市场决定了我......
  • Docker 查看容器的启动命令
    1、背景由于docker可能不是你本人部署的,可能会遇到服务需要迁移,但是又不知道之前部署的命令。runlike是一个用于查看Docker容器的启动命令的工具。它可以让您以一种更直观的方式查看容器的启动命令,包括容器的名称、镜像、挂载的卷以及其他参数。Runlike是一个用Python编写的工具......