兩種方式linux
yum install epel-release
還能夠替換清華源docker
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
可查看官方說明shell
sudo yum update -y
添加一個 docker
組json
groupadd docker
將使用 docker
的用戶添加進組裏app
useradd docker -g docker
將當期用戶添加進組curl
sudo usermod -aG docker $USER
CentOS7 以上系統,可經過 curl -sSL https://get.docker.com/ | sh
直接指向安裝腳本,這裏是用 yum
安裝。ide
sudo yum -y install docker-io
執行 docker version
檢查是否安裝成功:oop
Client version: 1.7.1 Client API version: 1.19 Go version (client): go1.4.2 Git commit (client): 786b29d/1.7.1 OS/Arch (client): linux/amd64 Get http:///var/run/docker.sock/v1.19/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
此時還沒有啓動 Docker Server 因此最後有提示。ui
目前國內已有幾個成熟的鏡像加速,這裏以 DockerCn
爲例:url
CentOS6 經過編輯 /etc/sysconfig/docker
文件的 other_args
參數實現鏡像加速。
# /etc/sysconfig/docker # # Other arguments to pass to the docker daemon process # These will be parsed by the sysv initscript and appended # to the arguments list passed to docker -d other_args="--registry-mirror=https://registry.docker-cn.com" DOCKER_CERT_PATH=/etc/docker # Resolves: rhbz#1176302 (docker issue #407) DOCKER_NOWARN_KERNEL_VERSION=1 # Location used for temporary files, such as those created by # # docker load and build operations. Default is /var/lib/docker/tmp # # Can be overriden by setting the following environment variable. # # DOCKER_TMPDIR=/var/tmp
此示例僅適用於 CentOS6
,若是已經啓動服務,須要重啓服務 service docker restart
。
啓動 Docker 服務
service docker start
另附上中止和重啓服務
service docker stop service docker restart
執行 docker version
Client version: 1.7.1 Client API version: 1.19 Go version (client): go1.4.2 Git commit (client): 786b29d/1.7.1 OS/Arch (client): linux/amd64 Server version: 1.7.1 Server API version: 1.19 Go version (server): go1.4.2 # /etc/sysconfig/docker Git commit (server): 786b29d/1.7.1 OS/Arch (server): linux/amd64
執行 docker info
Containers: 0 Images: 0 Storage Driver: devicemapper Pool Name: docker-202:2-1172437-pool Pool Blocksize: 65.54 kB Backing Filesystem: extfs Data file: /dev/loop0 Metadata file: /dev/loop1 Data Space Used: 305.7 MB Data Space Total: 107.4 GB Data Space Available: 34.62 GB Metadata Space Used: 733.2 kB Metadata Space Total: 2.147 GB Metadata Space Available: 2.147 GB Udev Sync Supported: true Deferred Removal Enabled: false Data loop file: /var/lib/docker/devicemapper/devicemapper/data Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata Library Version: 1.02.117-RHEL6 (2016-12-13) Execution Driver: native-0.2 Logging Driver: json-file Kernel Version: 2.6.32-358.el6.x86_64 Operating System: <unknown> CPUs: 8 Total Memory: 15.55 GiB Name: ecs-634b-0002 ID: IMEI:V37Q:FO5S:3GYL:X2UH:2ECU:V4RW:---------------------------
至此,安裝完成!