1

Docker Action 记录 作者: LinkSystem 2017/08/11

Docker Action 是我关于Docker-CE的实践记录,该实践的构建环境以下:

[root@core ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

[root@core ~]# docker version
Client:
 Version:      17.07.0-ce-rc2
 API version:  1.31
 Go version:   go1.8.3
 Git commit:   36ce605
 Built:        Mon Aug  7 23:43:46 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.07.0-ce-rc2
 API version:  1.31 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   36ce605
 Built:        Mon Aug  7 23:45:07 2017
 OS/Arch:      linux/amd64
 Experimental: false

配置Yum

# yum-utils的作用是添加 repo 文件
[root@core ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# 注意速度有点慢
[root@core ~]# sudo yum-config-manager \
>     --add-repo \
>     https://download.docker.com/linux/centos/docker-ce.repo
# 开启指定部分 repo
[root@core ~]# sudo yum-config-manager --enable docker-ce-edge
[root@core ~]# sudo yum-config-manager --enable docker-ce-test
# 更新缓存
[root@core ~]# sudo yum makecache fast

部署 Docker-CE

[root@core ~]# sudo yum install docker-ce

# 指定版本
# [root@core ~]# yum list docker-ce.x86_64  --showduplicates | sort -r
# sudo yum install docker-ce-<VERSION>

本地部署

# RPM下载地址: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
# 注意:Docker-CE 的依赖可以使用国内 Yum 源, 我配置的是阿里云的源
[root@core ~]# sudo yum install docker-ce/docker-ce-17.07.0.ce-0.2.rc2.el7.centos.x86_64.rpm

配置 Docker-CE

[root@core ~]# sudo systemctl start   docker
[root@core ~]# sudo systemctl enable  docker
# 配置 Docker 加速器
[root@core ~]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://df98fb04.m.daocloud.io
[root@core ~]# sudo systemctl restart docker

测试

[root@core ~]# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b04784fba78d: Pull complete 
Digest: sha256:9a4ec8dac439d00fff31bf41b23902bfd7f7465d4b4c8c950e572e7392f33c66
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 ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

部署脚本

[root@core ~]# curl -fsSL get.docker.com -o get-docker.sh
[root@core ~]# sudo sh get-docker.sh

卸载 Docker-CE

# Docker 旧版本
[root@core ~]# sudo yum remove docker \
>                   docker-common \
>                   docker-selinux \
>                   docker-engine
# Docker-CE 版本
[root@core ~]# sudo yum remove docker-ce
[root@core ~]# sudo rm -rf /var/lib/docker

linksystem
14 声望0 粉丝

海里的一尾鱼


下一篇 »
Docker-CE 监控