Cenots安装Docker

一、添加Docker仓库

1.安装

yum install -y yum-utils device-mapper-persistent-data lvm2

yum-utils:管理repository及扩展包的工具提供了yum-config-manager
yum-config-manager:管理仓库用

yum-config-manager的选项使用:

    yum-config-manager –add-repo“仓库路径” 添加仓库

    yum-config-manager –disable “仓库名"      禁用仓库

    yum-config-manager –enable  “仓库名”     启用仓库

device-mapper-persistent-data、lvm2:devicemapper存储驱动程序所必需的
devicemapper:Docker Engine基于Device Mapper提供的一种存储驱动
DeviceMapper:Linux系统中的高级卷管理技术框架


2.添加Docker仓库

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

命令完成后你会发现 /etc/yum.repo/ 下多了个docker-ce.repo


二、安装Docker CE

1.这条命令会安装最新版的Docker

yum install docker-ce

2.安装特定版Docker

查看Docker CE的版本,从高到底排序

yum list docker-ce --showduplicates | sort -r

[root@localhost yum.repos.d]# yum list docker-ce --showduplicates | sort -r
 * updates: mirrors.163.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
 * extras: mirrors.zju.edu.cn
docker-ce.x86_64            17.09.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.09.1.ce-1.el7.centos            @docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.2.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.2.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable 

安装特定版本对比上面的也就是两个前半截凑起来就是包名,比如:

docker-ce.x86_64            17.09.1.ce-1.el7.centos            docker-ce-stable 

安装就是:

yum install docker-ce-17.09.1.ce


三、下载一个image测试Docker

1.启动Docker

systemctl start docker

2.获取一个Docker image

docker search whalesay #这条命令会获取一个鲸鱼的小镜像

[root@localhost yum.repos.d]# docker search whalesay
NAME                            DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
docker/whalesay                 An image for use in the Docker demo tutorial    621                                     
mendlik/docker-whalesay         Docker whalesay image from training materi...   6                                       [OK]
sabs1117/whalesay               Whalesay with fortune phrases.                  1                                       
nikovirtala/whalesay            Tiny Go web service to print Moby Dock ASC...   1                                       [OK]
milanfort/whalesay              Modified docker/whalesay image that output...   1                                       
swinton/whalesay                whalesay, innit                                 1                                       
ojenge/whalesay                 from docker/whalesay                            1                                       
caibar/whalesay                 Builds automatizados.                           1                                       [OK]
jracionero/docker-whalesay      My smarter docker whalesay                      0                                       
puneethp/whalesay               Docker-Whalesay                                 0                                       
firecyberice/whalesay           Docker **Cloud** automated build for **amd...   0                                       
forsingh/whalesay               whalesay                                        0                                       [OK]
claytonrogers/docker-whalesay   Whalesay automated build                        0                                       [OK]
asakilan/pg-whalesay            My whalesay                                     0                                       
dhalljohnston/whalesay          whalesay                                        0                                       
whalebrew/whalesay                                                              0                                       
blaines/whalesay                                                                0                                       
tiagoferreira/whalesay          Whalesay image                                  0                                       
phyominhtun/whalesay            My whalesay image!                              0                                       
liuzhishan/docker-whalesay      docker-whalesay                                 0                                       
laveshin/whalesay               whalesay image                                  0                                       
hongxi/whalesay-fortunes        Demo, the whalesay-fortunes                     0                                       
jetolabs/whalesay               whalesay with fortune cookie messages           0                                       
nateliu/whalesay                first test of whalesay                          0                                       
bjarkebard/whalesay             testing whalesay                                0 


3.将image pull下来到本地

docker pull docker/whalesay

[root@localhost yum.repos.d]# docker pull docker/whalesay
Using default tag: latest
latest: Pulling from docker/whalesay
e190868d63f8: Pull complete 
909cd34c6fd7: Pull complete 
0b9bfabab7c1: Pull complete 
a3ed95caeb02: Pull complete 
00bf65475aba: Pull complete 
c57b6bcc83e3: Pull complete 
8978f6879e2f: Pull complete 
8eed3712d2cf: Pull complete 
Digest: sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b
Status: Downloaded newer image for docker/whalesay:latest

4.查看刚刚pull下来的镜像

docker images

[root@localhost yum.repos.d]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker/whalesay     latest              6b362a9f73eb        2 years ago         247MB

5.启动容器打出hello world

docker run docker/whalesay cowsay hello world

[root@localhost yum.repos.d]# docker run docker/whalesay cowsay hello world
 _____________ 
< hello world >
 ------------- 
    \
     \
      \     
                    ##        .            
              ## ## ##       ==            
           ## ## ## ##      ===            
       /""""""""""""""""___/ ===        
  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~   
       \______ o          __/            
        \    \        __/             
          \____\______/   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值