Docker Install
docker要求操作系统为centos7,目前centos 7的镜像站都已经集合了docker。安装步骤如下:
1.使用yum从软件仓库安装docker
yum -y install docker
2.首先启动docker的守护进程
systemctl start docker
3.如果想要docker在系统启动时运行,执行
chkconfig docker on or systemctl enable docker
[注]docker在centos上好像和防火墙又冲突,应用防火墙规则后可能导致docker无法联网,重启docker即可。
由于众所周知的原因,国内安装docker和docker周边的一些工具,访问docker hub的速度非常慢。使用daocloud提供的镜像站点(http://get.daocloud.io/#install-docker),这个站点提供了docker安装文件,Boot2Docker工具的高速下载,并且提供Docker Hub加速器服务器,有效提升docker pull image的速度。
使用daocloud镜像站点在Linux安装docker步骤如下
Docker的安装资源文件存放在Amazon S3,会间歇性连接失败。所以安装Docker的时候,会比较慢。可通过执行下面命令,告诉安装docker
curl -sSL https://get.daocloud.io/docker | sh
[注明]适用于Ubuntu、Debian、CentOS等大部分Linux,会3小时同步一次Docker官方资源。
安装体验版或测试版,体验最新Docker。
curl -sSL https://get.daocloud.io/docker-experimental | sh
curl -sSL https://get.daocloud.io/docker-test | sh
如果安装不成功,可以选择使用二进制包安装方式
# To install, run the following commands as root:
curl -fsSLO https://get.daocloud.io/docker/builds/Linux/x86_64/docker-17.03.0-ce.tgz && tar --strip-components=1 -xvzf docker-17.03.0-ce.tgz -C /usr/local/bin
# Then start docker in daemon mode:
/usr/local/bin/dockerd
当上述安装完成后,要加载daocloud的加速器,否则会报错
报错信息:
[anne@weft-lsb ~]$ docker pull hello-world
Using default tag: latest
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: read tcp 10.200.57.124:53822->50.17.62.194:443: read: connection reset by peer
[anne@weft-lsb ~]$ curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -shttp://f18f8819.m.daocloud.iodocker version >= 1.12## 加载daocloud加速器
[sudo] password for anne:
{"registry-mirrors": ["http://f18f8819.m.daocloud.io"]}
Success.
You need to restart docker to take effect: sudo systemctl restart docker
然后重启docker服务。
[root@weft-lsb ~]# systemctl restart docker
重启后,到anne用户,运行docker run hello-world
[anne@weft-lsb ~]$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
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:
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
[anne@weft-lsb ~]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f35adc1796b6 hello-world "/hello" 8 seconds ago Exited (0) 7 seconds ago zen_allen
[anne@weft-lsb ~]$