Docker的安装(一)

文章
林里克斯

Linux下安装体验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
#国外官方库

$ sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
$ sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/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            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~

版权协议须知!

本篇文章来源于 Uambiguous ,如本文章侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意

965 0 2018-01-13


分享:
icon_mrgreen.gificon_neutral.gificon_twisted.gificon_arrow.gificon_eek.gificon_smile.gificon_confused.gificon_cool.gificon_evil.gificon_biggrin.gificon_idea.gificon_redface.gificon_razz.gificon_rolleyes.gificon_wink.gificon_cry.gificon_surprised.gificon_lol.gificon_mad.gificon_sad.gificon_exclaim.gificon_question.gif
博主卡片
林里克斯 博主大人
一个致力于Linux的运维平台
运维时间
搭建这个平台,只为分享及记载自己所遇之事和难题。

现在时间 2024-05-09

今日天气
站点统计
  • 文章总数:240篇
  • 分类总数:29个
  • 评论总数:10条
  • 本站总访问量 219460 次

@奥奥

@Wong arrhenius 牛比

@MakerFace 厉害了!