阿里云ECS安装Docker

时间:2023-03-09 16:57:55
阿里云ECS安装Docker

阿里云ESC系统信息,官方说2.6内核运行docker服务可能会不稳定;

$ uname -a
Linux iZ259dixwg8Z 2.6.-431.23..el6.x86_64 # SMP Thu Jul :: UTC x86_64 x86_64 x86_64 GNU/Linux

安装过程参考: http://www.docker.org.cn/book/install/install-docker-on-rhel-29.html

1. 本机未安装curl,需要先安装curl:

$ yum install curl

2. 执行docker安装脚本:

$ curl -sSL https://get.docker.com/ | sh 

3. 启动docker服务,启动过程中遇到了一些问题,本文后面统一说明;

$ service docker start

4. 查看docker版本:

$ docker version
Client version: 1.7.
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64

5. 验证安装,显示以下信息表示成功;

$ 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:
. The Docker client contacted the Docker daemon.
. The Docker daemon pulled the "hello-world" image from the Docker Hub.
. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
. 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/

service docker start启动过程中遇到的问题:

查看日志:

docker -h

或者:

cat /var/log/docker

问题1:

symbol dm_task_get_info_with_deferred_remove, version Base not defined in file     libdevmapper.so.1.02 with link time reference

解决方法:

$ yum upgrade device-mapper-libs

问题2:

Error starting daemon: Error initializing network controller: Error cr    eating default "bridge" network: can't find an address range for interface "docker0"

解决方法:

route del -net 172.16.0.0/12

如果想每次服务器启动都生效的话,可以修改下路由文件,去掉下面的172.16.0.0/12 via 10.170.247.247 dev eth0 这一行

/etc/sysconfig/network-scripts/route-eth0

10.0.0.0/ via 10.170.247.247 dev eth0
100.64.0.0/ via 10.170.247.247 dev eth0
172.16.0.0/ via 10.170.247.247 dev eth0
192.168.0.0/ via 10.170.247.247 dev eth0

该问题具体原因查看:http://hanjianwei.com/2014/07/30/docker-on-aliyun/

问题3:在docker run hello-world的时候,设备突然重启了,重启后执行此命令显示

$ docker run hello-world
Error response from daemon: EOF

解决方法:

$ docker pull hello-world