1.2 安装Docker
各主流操作系统平台都支持Docker的使用,包括Windows操作系统、Linux操作系统以及Mac OS操作系统等。目前最新的RHEL、CentOS以及Ubuntu操作系统官方软件源中都已经默认自带了Docker包,可以直接安装使用,也可以用Docker自己的YUM源进行配置。
在CentOS操作系统下安装Docker有两种方式:一种是使用curl获得Docker的安装脚本进行安装,另一种是使用YUM仓库进行安装。
注意
目前Docker只支持64位操作系统。
1.安装最新版本Docker依赖环境
[root@localhost ~]#yum install -y yum-utils device-mapper-persistent-data lvm2
[root@localhost ~]#yum-config-manager --add-repo https://download.docker.com/linux/centos/Docker-ce.repo
[root@localhost ~]# more /etc/yum.repos.d/Docker-ce.repo
[Docker-ce-stable]
name=docker CE Stable -$basearch
baseurl=https://download.Docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-stable-debuginfo]
name=docker CE Stable - Debuginfo $basearch
baseurl=https://download.Docker.com/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-stable-source]
name=docker CE Stable - Sources
baseurl=https://download.Docker.com/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-edge]
name=docker CE Edge -$basearch
baseurl=https://download.Docker.com/linux/centos/7/$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-edge-debuginfo]
name=docker CE Edge - Debuginfo $basearch
baseurl=https://download.Docker.com/linux/centos/7/debug-$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-edge-source]
name=docker CE Edge - Sources
baseurl=https://download.Docker.com/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-test]
name=docker CE Test -$basearch
baseurl=https://download.Docker.com/linux/centos/7/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-test-debuginfo]
name=docker CE Test - Debuginfo $basearch
baseurl=https://download.Docker.com/linux/centos/7/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-test-source]
name=docker CE Test - Sources
baseurl=https://download.Docker.com/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-nightly]
name=docker CE Nightly -$basearch
baseurl=https://download.Docker.com/linux/centos/7/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-nightly-debuginfo]
name=docker CE Nightly - Debuginfo $basearch
baseurl=https://download.Docker.com/linux/centos/7/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.Docker.com/linux/centos/gpg
[Docker-ce-nightly-source]
name=docker CE Nightly - Sources
baseurl=https://download.Docker.com/linux/centos/7/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
2.安装Docker并设置为开机自动启动
[root@localhost ~]#yuminstalldocker-ce
[root@localhost ~]#systemctlstartdocker
[root@localhost ~]#systemctlenabledocker
安装好的Docker系统有两个程序:Docker服务端和Docker客户端。其中,Docker服务端是一个服务进程,负责管理所有容器。Docker客户端则充当Docker服务端的远程控制器,用来控制Docker的服务端进程。大部分情况下,Docker服务端和客户端运行在一台机器上。
3.通过检查Docker版本查看Docker服务
[root@localhost ~]# dockerversion
Client:
Version: 18.03.0-ce
APIversion: 1.37
Goversion: go1.9.4
Gitcommit: 0520e24
Built: Wed Mar2123:09:152018
OS/Arch:linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version:18.03.0-ce
APIversion: 1.37(minimumversion1.12)
Goversion: go1.9.4
Gitcommit: 0520e24
Built: Wed Mar2123:13:032018
OS/Arch: linux/amd64
Experimental:false