公司linux伺服器基本使用的Centos,以下切換為Centos進行docker的操作。
檢視系統版本
[root@Sonar-104 ~]# cat /etc/redhat-release CentOS release 6.5 (Final)
安裝docker
CentOS6
對於 CentOS6,可以使用 EPEL 庫安裝 Docker,命令如下
$ sudo yum install http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm $ sudo yum install docker-io
CentOS7
CentOS7 系統 CentOS-Extras
庫中已帶 Docker,可以直接安裝:
$ sudo yum install docker
安裝之後啟動 Docker 服務,並讓它隨系統啟動自動載入。
$ sudo service docker start $ sudo chkconfig docker on
Centos 6.5會因為核心問題無法啟動docker並報錯 WARN[0000] You are running linux kernel version 2.6.32-431.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
解決辦法:
yum upgrade device-mapper-libs
檢視docker程式是否啟動:
ps -aux | grep docker
docker監聽內網的配置檔案/etc/sysconfig/docker內容:
# /etc/sysconfig/docker # Modify these options if you want to change the way the docker daemon runs OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false' if [ -z "${DOCKER_CERT_PATH}" ]; then DOCKER_CERT_PATH=/etc/docker fi # Do not add registries in this file anymore. Use /etc/containers/registries.conf # from the atomic-registries package. # # docker-latest daemon can be used by starting the docker-latest unitfile. # To use docker-latest client, uncomment below lines #DOCKERBINARY=/usr/bin/docker-latest #DOCKERDBINARY=/usr/bin/dockerd-latest #DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest #DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest