【安装docker】使用云主机(centos7.6)安装和验证docker环境

举报
Hait8090 发表于 2019/07/08 11:52:09 2019/07/08
【摘要】 本文主要是讲述了在华为云的云主机上安装docker环境并且通过一个简单的实验验证docker。使用的是centos7.6的操作系统。
  • 版本要求:查看内核版本,需要大于3.10

[root@ecs-1021 ~]# uname -r 

image.png

  • 如果内核版本过低,需要更新内核:

[root@ecs-1021 ~]# yum update

  • Docker所需安装包所在网址

https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

image.png

  • 将rpm包直接下载到系统中

[root@ecs-1021 ~]# wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x8
[root@ecs-1021 ~]# wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.09.7-3.el7.x86_64.rpm6_64.rpm

[root@ecs-1021 ~]# wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-18.09.7-3.el7.x86_64.rpm

image.png 

  • 安装docker(注意安装的顺序)

[root@ecs-1021 ~]# yum install -y containerd.io-1.2.6-3.3.el7.x86_64.rpm

[root@ecs-1021 ~]# yum -y install docker-ce-cli-18.09.7-3.el7.x86_64.rpm

[root@ecs-1021 ~]# yum -y install docker-ce-18.09.7-3.el7.x86_64.rpm

  • 查看docker版本

[root@ecs-1021 ~]# docker --version 

image.png 

  • 启动docker并设置开机启动

[root@ecs-1021 ~]# systemctl start docker 

[root@ecs-1021 ~]# systemctl enable docker 

image.png

  • 测试

[root@ecs-1021 ~]# docker run hello-world

Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world

1b930d010525: Pull complete

Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8

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/


【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。