在CentOS 7上安装Docker环境

官网文档:https://docs.docker.com/engine/installation/linux/centos/ ,本文大部分是照搬官方文档写的,若是你英文还不错,那么就直接移步官方文档吧,若是你英文实在是不行,那就勉强看一下本人这生涩的翻译~linux

如下操做均在root用户下完成程序员

1.配置yum软件库

为保证安装的成功,首先使用yum update更新Yum包,表示个人好多yum包都须要更新,1500+的包,若是你像我同样很久没有更新过,那就耐心等候吧。docker

而后在yum软件库中新增docker的配置:ubuntu

#  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.安装Docker

有了yum软件库的配置以后,安装也变得异常的简单,只须要如下一句便可:centos

# yum install docker-engine

3.启动Docker

一切就绪以后,使用start命令来启动Docker守护进程:bash

# service docker start

4.输出hello-world

程序员貌似跟hello-world有仇,有事儿没事就打印人家一下,玩docker我们当前也不例外,先来个hello-world吧,这里的基本原理是利用人家已经写好的hello-world镜像,下载到本地,而后把他运行起来~网络

使用如下命令:app

# docker run hello-world

而后控制端会输出相似于以下的信息,就证实咱们的docker环境安装成功了~ide

在这里,我第一次失败了~显示:ui

Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fhello-world%3Apull&service=registry.docker.io: net/http: TLS handshake timeout.
See 'docker run --help'.

而后我又来了一次就行了,应该是墙的缘由吧,看着是网络访问失败了~

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
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.
 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 Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
相关文章
相关标签/搜索