一、docker安装的三种方式(install for linux):

### --- docker安装的三种方式(install for linux):

~~~ script:脚本的方式;
~~~ yum:yum方式安装;
~~~ rpm:rpm包安装(推荐使用)

二、docker部署

### --- 方式一:script install

[root@localhost ~]# yum update
[root@localhost ~]# curl -sSL https://get.docker.com/ | sh
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
[root@localhost ~]# docker run hello-world
### --- 方式二:yum install

[root@localhost ~]# yum update
[root@localhost ~]# cat >/etc/yum.repos.d/docker.repo <<-EOF
[dockerrepo]
name=Docker Repository
baseurl=https:///repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https:///gpg EOF
[root@localhost ~]# yum install docker
### --- 方式三:rpm install 

https://download.docker.com/linux/centos/7/x86_64/stable/Packages

三、通过rpm安装docker服务

### --- rpm包下载:

~~~ # 地址:https://download.docker.com/linux/centos/7/x86_64/stable/Packages
~~~ # 下载:docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
~~~ # docker-selinux:docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
### --- 环境检查:

[root@localhost ~]# getenforce
Disabled
[root@localhost ~]# systemctl status firewalld.service
[root@localhost ~]# yum install -y iptables-services
[root@localhost ~]# systemctl start iptables.service
[root@localhost ~]# systemctl enable iptables.service
[root@localhost ~]# iptables -F // 清空防火墙默认规则
[root@localhost ~]# service iptables save // 保存防火墙规则
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@localhost ~]# yum update // 更新软件包

[root@localhost docker]# ls
docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
### --- 安装docker rpm包和selinux包

[root@localhost docker]# yum install -y *
Installed:
docker-ce.x86_64 0:17.03.0.ce-1.el7.centos docker-ce-selinux.noarch 0:17.03.0.ce-1.el7.centos
Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7
libtool-ltdl.x86_64 0:2.4.2-22.el7_3 policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
Complete!
root@localhost docker]# systemctl start docker.service
[root@localhost docker]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
### --- 测试hello-world容器

[root@localhost docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally // hello-world镜像名称:latest版本号v1/v2/v3版本号,若不加版本号,默认latest:代表最新稳定版
latest: Pulling from library/hello-world // pulling下载镜像hello-world镜像
0e03bdcc26d7: Pull complete
Digest: sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.











Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of sinks, and I am ready to depart

                                                                                                                                                   ——W.S.Landor