1 #!/bin/bash 2 3 # 4 # 無人值守安裝 docker 5 # 6 7 # 8 # 1、關閉SELinux 9 # 10 11 setenforce 0 12 sed -i 's/SELINUX=enforcinf/SELINUX=disabled/' /etc/sysconfig/selinux 13 14 # 15 # 2、配置阿里雲的 docker-engine YUM 源 16 # 17 18 tee /etc/yum.repos.d/docker.repo <<-'EOF' 19 [dockerrepo] 20 name=Docker Repository 21 baseurl=http://mirrors.aliyun.com/docker-engine/yum/main/centos/$releasever/ 22 enabled=1 23 gpgcheck=1 24 gpgkey=http://mirrors.aliyun.com/docker-engine/yum/gpg 25 EOF 26 27 # 28 # 3、安裝 docker-engine 29 # 30 31 yum install -y docker-engine 32 33 # 34 # 4、啟動 docker 並設定 docker 開機自動執行 35 # 36 37 service docker start 38 chkconfig docker on 39 40 # 41 # 5、驗證 docker 安裝成功 42 # 43 44 docker version