(docker第二记)centos 7 安装docker

 

1、准备

 


系统要求CentOS 7.X 以上版本,内核至少3.10,64-bit
1.1、使用 uname -r 检查 kernel (内核)版本
[root@localhost ~]# uname -r
3.10.0-693.5.2.el7.x86_64

1.2、设置阿里CentOS仓库为了更新插件/软件包时更加流畅
步骤一:执行下面命令下载CentOS-7镜像仓库,以CentOS-Base.repo名字保存在/etc/yum.repos.d/目录下。
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
步骤二:执行下面命令,将服务器上的软件包信息先在本地缓存,以提高搜索安装软件的速度。
[root@localhost ~]# yum makecache

步骤三:执行下面命令更新软件包
[root@localhost ~]# yum update

1.3、添加 yum 仓库
[root@localhost ~]#sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

 

 

 

 

 

2、安装

 


2.1、安装docker
[root@localhost ~]# sudo yum install docker-engine

2.2、启动docker服务
[root@localhost ~]# sudo systemctl enable docker.service

2.3、启动docker守护
[root@localhost ~]# sudo systemctl start docker

 

 

 

 

 

 

 

 

3、验证

 


[root@localhost ~]# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
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://cloud.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
整个过程是这样的:
Docker 客户端连接到 Docker 守护进程; 
Docker 守护进程从 Docker Hub 中拉取名为 “hello-world” 的 image(镜像); 
Docker 守护程序从该 image 中创建新的容器,该容器执行输出动作,输出的内容就是上面所看到的; 
Docker 守护程序将输出流到 Docker 客户端并发送你的终端显示。

 

 

 

 

 

 

 

4、查看docker image

 


[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest f2a91732366c 3 weeks ago 1.85kB

转自原创:https://blog.csdn.net/cool_summer_moon/article/details/78791355

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值