第三十五章 Centos7下rpm安装Docker-17.03

一、安装依赖

[root@cos-ftp ~]# sudo yum install libxml2-devel libcurl-devel -y

二、下载Docker安装包

# 1.下载地址:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
# 2.下载rpm包:
docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm 
docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm   

三、上传Docker安装包

# 1.新建docker安装包存放目录
[root@cos-ftp ~]# mkdir -p docker
[root@cos-ftp ~]# cd docker/

# 2.上传安装包
[root@cos-ftp docker]# rz

# 3.查看安装包
[root@cos-ftp docker]# ll
总用量 19096
-rw-r--r-- 1 root root 19521288 10月 15 14:21 docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
-rw-r--r-- 1 root root    29108 10月 15 14:21 docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm

四、安装Docker

[root@cos-ftp docker]# yum -y install *.rpm

五、修改Docker数据目录

# 1.新建Docker数据存放目录
[root@cos-ftp docker]# mkdir -p /data/docker

# 2.修改Docker启动文件
[root@cos-ftp docker]# vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target firewalld.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 --graph=/data/docker
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

[Install]
WantedBy=multi-user.target

六、启动Docker

# 1.重载system
[root@cos-ftp docker]# sudo systemctl daemon-reload

# 2.启动Docker
[root@cos-ftp docker]# sudo systemctl restart docker

七、验证Docker

# 1.查看Docker服务状态
[root@cos-ftp docker]# sudo 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 六 2022-10-15 15:30:41 CST; 1 day 18h ago
     Docs: https://docs.docker.com
 Main PID: 16116 (dockerd)
    Tasks: 37
   Memory: 550.8M
   CGroup: /system.slice/docker.service
           ├─16116 /usr/bin/dockerd --graph=/data/docker
           ├─16121 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --...
           ├─16524 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172...
           └─16529 docker-containerd-shim c31c854131acff255ac6c3b562d2ce32cae6470b1c45656a9b5cbf000134...
           
# 2.验证Docker数据目录及版本
[root@cos-ftp docker]# docker info |grep -E 'Server Version|Docker Root Dir'
Server Version: 17.03.0-ce
Docker Root Dir: /data/docker

八、上传镜像到服务器

1.下载镜像包

镜像包地址:https://activity-dev-1255598736.cos.ap-guangzhou.myqcloud.com/cos-csi-image/caas-file-script-1.0.tar?q-sign-algorithm=sha1&q-ak=AKID1kpH1OJFFzLEwFVlqEvn4YdOCZ2WoYyC2bo1ejoVPz48Pm7OlL5J_mJc2iz_MYax&q-sign-time=1665991787;1665995387&q-key-time=1665991787;1665995387&q-header-list=host&q-url-param-list=&q-signature=12dfec0ac82a6a6266f2dc12ca8c41d718ae27b0&x-cos-security-token=***************

2.上传镜像

[root@cos-ftp ~]# rz
[root@cos-ftp ~]# ll
总用量 2968316
-rw-r--r-- 1 root root  841987072 10月 17 15:32 caas-file-script-1.0.tar

3.加载镜像

# 1.加载caas-file-script-1.0.tarr镜像
[root@cos-ftp ~]# docker load -i caas-file-script-1.0.tar
612be2c668b1: Loading layer 320.7 MB/320.7 MB
7d01265ad2ea: Loading layer 3.584 kB/3.584 kB
f37f0c4b685f: Loading layer 343.3 MB/343.3 MB
47d2f607eb5d: Loading layer 48.83 MB/48.83 MB
31336b7d6b01: Loading layer 4.096 kB/4.096 kB
Loaded image ID: sha256:eee591c193605078f0ef9fb9b8c1c4a2c7bd577c72cd2c86c4a0f518f9ba2b4e

# 2.查看镜像
[root@cos-ftp ~]# docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
<none>                                 <none>              eee591c19360        About an hour ago   826 MB

# 3.打上原始镜像标签
[root@cos-ftp ~]# docker tag eee591c19360 caas-file-script-202210171124:latest

# 4.再次查看镜像
[root@cos-ftp ~]# docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
caas-file-script-202210171124          latest              eee591c19360        About an hour ago   826 MB

九、运行Docker

1.运行Docker容器

[root@cos-ftp ~]# docker run \
 -itd  \
 -v /data/cos/prod/release_data:/data/cos \
 -v /data/cos_ftp:/data/cos_ftp \
 -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime \
 --restart always \
 --privileged=true \
 --name caas-file-script \
 caas-file-script-202210171124:latest
 8075d3870807b11cc138fd42c441e2306149fe95f6e9b932d7533f1ab2ce8377

2.查看容器

[root@cos-ftp ~]# docker ps
CONTAINER ID        IMAGE                                  COMMAND                  CREATED             STATUS              PORTS               NAMES
8075d3870807        caas-file-script-202210171124:latest   "/data/FileBufferZ..."   11 seconds ago      Up 8 seconds                            caas-file-script

3.检查容器目录

[root@cos-ftp ~]# docker exec -it 8075d3870807 /bin/bash

root@8075d3870807:/# df -h
Filesystem                 Size  Used Avail Use% Mounted on
overlay                    483G  2.4G  456G   1% /
tmpfs                      1.9G     0  1.9G   0% /dev
tmpfs                      1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/datavg-datalv  483G  2.4G  456G   1% /data/cos_ftp
/dev/mapper/centos-root     50G  5.5G   45G  11% /usr/share/zoneinfo/Asia/Shanghai
cosfs                      256T     0  256T   0% /data/cos
shm                         64M     0   64M   0% /dev/shm

posted @ 2022-10-20 11:12  年少纵马且长歌  阅读(397)  评论(0编辑  收藏  举报