JobPlus知识库 互联网 系统架构 文章
docker在linux中的安装

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

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

  • 1

步骤二:执行下面命令,将服务器上的软件包信息先在本地缓存,以提高搜索安装软件的速度。

[root@localhost ~]# yum makecache

  • 1

步骤三:执行下面命令更新软件包

[root@localhost ~]# yum update

  • 1

1.3、添加 yum 仓库

[root@localhost ~]#sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'[dockerrepo] name=Docker Repositorybaseurl=https://yum.dockerproject.org/repo/main/centos/7/enabled=1gpgcheck=1gpgkey=https://yum.dockerproject.org/gpgEOF

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

2、安装 
2.1、安装docker

[root@localhost ~]# sudo yum install docker-engine

  • 1

2.2、启动docker服务

[root@localhost ~]# sudo systemctl enable docker.service

  • 1

2.3、启动docker守护

[root@localhost ~]# sudo systemctl start docker

  • 1

3、验证

[root@localhost ~]# sudo docker run hello-world

  • 1

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 imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZEhello-world         latest              f2a91732366c        3 weeks ago         1.85kB

  • 1
  • 2
  • 3

以上就完了docker在CentOS中的安装和启动


如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

¥ 打赏支持
64人赞 举报
分享到
用户评价(0)

暂无评价,你也可以发布评价哦:)

扫码APP

扫描使用APP

扫码使用

扫描使用小程序