centos 7.6.1810安装与使用docker 18.09.6

1 升级centos内核

《CentOS 7.6.1810 升级内核 由 3.10.0-862.el7.x86_64 升级到 4.4.186-1.el7.elrepo.x86_64》:https://blog.csdn.net/CleverCode/article/details/107165174

2 查看CentOS

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@localhost ~]# uname -a
Linux localhost.localdomain 4.4.229-1.el7.elrepo.x86_64 #1 SMP Wed Jul 1 10:43:08 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]#

3 下载

进入到 https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
下载

# 1 守护进程与操作系统API(在本例中是LXC-Linux容器)接口
* containerd.io-1.2.5-3.1.el7.x86_64.rpm

# 2 Docker守护进程
* docker-ce-18.09.6-3.el7.x86_64.rpm

# 3 控制守护程序的CLI工具
* docker-ce-cli-18.09.6-3.el7.x86_64.rpm

# 4 安全软件
* docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm

4 安装

# sudo yum -y install ./docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm

# sudo yum -y install ./containerd.io-1.2.5-3.1.el7.x86_64.rpm

# sudo yum -y install ./docker-ce-cli-18.09.6-3.el7.x86_64.rpm

# sudo yum -y install ./docker-ce-18.09.6-3.el7.x86_64.rpm

5 启动docker

# systemctl start docker
[root@localhost ~]# ps axu | grep docker
root       7253  2.0  7.0 525652 70128 ?        Ssl  03:10   0:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root       7395  0.0  0.2 116912  2436 pts/0    S+   03:10   0:00 grep --color=auto docker
[root@localhost ~]#

6 验证docker

1 查看版本

[root@localhost ~]# docker -v
Docker version 18.09.6, build 481bc77156
[root@localhost ~]#

2 运行run hello-world

docker run hello-world
[root@localhost ~]# docker ps --all
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
7f5fd8203e0b        hello-world         "/hello"            55 seconds ago      Exited (0) 53 seconds ago                       eager_einstein
7a08bc668621        hello-world         "/hello"            27 minutes ago      Exited (0) 27 minutes ago                       inspiring_fermi
[root@localhost ~]#

7 镜像加速

国内从 DockerHub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。
1 vi /etc/docker/daemon.json

{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn","http://hub-mirror.c.163.com","https://dockerhub.mirrors.nwafu.edu.cn"], 
  
  "insecure-registries": ["http://harbor.clevercode.net","http://harbor01.clevercode.net","http://harbor02.clevercode.net","http://harbor03.clevercode.net"],
  "max-concurrent-downloads": 10,
  "log-driver": "json-file",
  "log-level": "warn",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
    },
  "data-root": "/var/lib/docker"
}

registry-mirrors 为docker镜像库,配置了国内镜像之后,下载速度会快不少
insecure-registries 为不安全的镜像,我们的Registry配置在这里,push或者pull镜像的机器都需要配置。私有镜像库。

2 启动服务

# systemctl daemon-reload
# systemctl restart docker

3 查看

#  docker info

Registry Mirrors:
 https://docker.mirrors.ustc.edu.cn/
 http://hub-mirror.c.163.com/
 https://dockerhub.mirrors.nwafu.edu.cn/
 

参考文档

https://www.cnblogs.com/cobcmw/p/12514444.html

你可能感兴趣的:(容器)