功能
归档
464
2017 年 03 月 16 日
Docker的安装(一)

实验平台:CentOS 7.4
kernel版本:3.10.0-693.11.1.el7.x86_64(3.8+)
Docker版本:17.05.0-ce
至少使用CentOS 64位7.1及更高版本x86_64



一、搭建环境


1.Docker官网

https://docs.docker.com/
Docker有两个版本:Community Edition(CE)和Enterprise Edition(EE)。

Docker Community Edition(CE)非常适合希望开始使用Docker并尝试使用基于容器的应用程序的开发人员和小团队。Docker CE有两个更新通道,稳定和边缘:
Stable每季度为您提供可靠的更新
Edge每个月都会为您提供新功能

Docker企业版(EE)专为企业开发和IT团队而设计,他们可以在生产规模上构建,发布和运行关键业务应用程序。

2.yum安装

安装依赖

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

创建Docker EE的yum仓库

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

Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

可选:启用边缘和测试存储库。

$ yum-config-manager --enable docker-ce-edge
$ yum-config-manager --enable docker-ce-test

禁用

$ yum-config-manager --disable docker-ce-edge

注意:从Docker 17.06开始,稳定版本也被推到边缘并测试版本库。


二、安装Docker


1.列出和排序您的回购中可用的版本。此示例按版本号排序结果,从最高到最低,

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

Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.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

2.安装docker

$ yum -y install docker-ce.x86_64
#这样安装默认都是安装最新版本
#指定版本安装用如下:
$ yum -y install docker-ce-17.06.2.ce-1.el7.centos

2.启动Docker

$ systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
$ systemctl start docker.service

3.查看版本

$ docker version

Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:25 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:25 2017
 OS/Arch:      linux/amd64
 Experimental: false

4.通过运行hello-world 映像验证安装是否正确。

$ docker run hello-world

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/engine/userguide/


三、卸载Docker


1.使用yum卸载docker

$  yum list installed | grep docker

docker-ce.x86_64                     18.03.1.ce-1.el7.centos        @docker-ce-stable

2.删除docker

$ yum -y remove docker-ce.x86_64

3.删除镜像和仓库

rm -rf /var/lib/docker/

Over~

留言
Loading...

发表评论

电子邮件地址不会被公开。 必填项已用*标注