栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

centos 7 安装Docker

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

centos 7 安装Docker

一、安装Docker
sudo yum-config-manager 
>     --add-repo 
>     https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@dbnode8 system]# sudo yum -y install docker-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:20.10.10-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-20.10.10-3.el7.x86_64
--> Processing Dependency: containerd.io >= 1.4.1 for package: 3:docker-ce-20.10.10-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-20.10.10-3.el7.x86_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.10-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
---> Package containerd.io.x86_64 0:1.4.11-3.1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:20.10.10-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.10-3.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:20.10.10-3.el7 will be installed
--> Running transaction check
---> Package docker-scan-plugin.x86_64 0:0.9.0-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================
 Package                                 Arch                 Version                                   Repository                      Size
=============================================================================================================================================
Installing:
 docker-ce                               x86_64               3:20.10.10-3.el7                          docker-ce-stable                23 M
Installing for dependencies:
 container-selinux                       noarch               2:2.119.2-1.911c772.el7_8                 extras                          40 k
 containerd.io                           x86_64               1.4.11-3.1.el7                            docker-ce-stable                28 M
 docker-ce-cli                           x86_64               1:20.10.10-3.el7                          docker-ce-stable                29 M
 docker-ce-rootless-extras               x86_64               20.10.10-3.el7                            docker-ce-stable               8.0 M
 docker-scan-plugin                      x86_64               0.9.0-3.el7                               docker-ce-stable               3.7 M

Transaction Summary
=============================================================================================================================================
Install  1 Package (+5 Dependent packages)

Total download size: 92 M
Installed size: 376 M
Downloading packages:
(1/6): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                                           |  40 kB  00:00:00     
(2/6): docker-ce-20.10.10-3.el7.x86_64.rpm                                                                            |  23 MB  00:00:01     
(3/6): docker-ce-cli-20.10.10-3.el7.x86_64.rpm                                                                        |  29 MB  00:00:01     
(4/6): docker-ce-rootless-extras-20.10.10-3.el7.x86_64.rpm                                                            | 8.0 MB  00:00:00     
(5/6): docker-scan-plugin-0.9.0-3.el7.x86_64.rpm                                                                      | 3.7 MB  00:00:00     
(6/6): containerd.io-1.4.11-3.1.el7.x86_64.rpm                                                                        |  28 MB  00:00:08     
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                         11 MB/s |  92 MB  00:00:08     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                        1/6 
setsebool:  SELinux is disabled.
  Installing : containerd.io-1.4.11-3.1.el7.x86_64                                                                                       2/6 
  Installing : 1:docker-ce-cli-20.10.10-3.el7.x86_64                                                                                     3/6 
  Installing : docker-scan-plugin-0.9.0-3.el7.x86_64                                                                                     4/6 
  Installing : 3:docker-ce-20.10.10-3.el7.x86_64                                                                                         5/6 
  Installing : docker-ce-rootless-extras-20.10.10-3.el7.x86_64                                                                           6/6 
  Verifying  : docker-ce-rootless-extras-20.10.10-3.el7.x86_64                                                                           1/6 
  Verifying  : docker-scan-plugin-0.9.0-3.el7.x86_64                                                                                     2/6 
  Verifying  : 3:docker-ce-20.10.10-3.el7.x86_64                                                                                         3/6 
  Verifying  : containerd.io-1.4.11-3.1.el7.x86_64                                                                                       4/6 
  Verifying  : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                                        5/6 
  Verifying  : 1:docker-ce-cli-20.10.10-3.el7.x86_64                                                                                     6/6 

Installed:
  docker-ce.x86_64 3:20.10.10-3.el7                                                                                                          

Dependency Installed:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8    containerd.io.x86_64 0:1.4.11-3.1.el7      docker-ce-cli.x86_64 1:20.10.10-3.el7   
  docker-ce-rootless-extras.x86_64 0:20.10.10-3.el7     docker-scan-plugin.x86_64 0:0.9.0-3.el7   

Complete!

安装成功!

二、开启Docker
sudo systemctl start docker

测试:docker run hello-world

docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:37a0b92b08d4919615c3ee023f7ddb068d12b8387475d64c622ac30f45c29c51
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

证明安装成功,并成功开启应用。

三、关闭Docker
systemctl stop docker
四、重启Docker
systemctl restart docker
五、配置镜像加速文件

国内网络较慢,拉取docker镜像比较慢,因此需要配置镜像加速文件 /etc/docker/daemon.json

vi /etc/docker/daemon.json

修改daemon.json文件如下所示:

{
"registry-mirrors":["https://tnxkcsol.mirror.aliyuncs.com"]
}

至此,Docker安装成功!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/422365.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号