005、執行第一個容器-視訊(2018-12-20 週四)

三角形發表於2018-12-20
 
直接看上面gif動畫即可
---------------------------------  華麗的分割線  -------------------------------------------------------------
為了錄視訊方便,自動部署docker的指令碼做了以下更新:
    1、使用阿里雲映象站代替docker源站
    2、優化測試部分的顯示效果
 
#!/bin/bash
 
#    該指令碼基於 Ubuntu 16.04 64位 作業系統
 
#    設定主機名
echo 'docker-lab' >/etc/hostname
hostname docker-lab
 
#    配置Ubuntu源
cat >/etc/apt/sources.list << EOF
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
 
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
 
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
 
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
EOF
 
#    配置docker源(使用阿里雲映象站)
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
#add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
 
#    安裝docker
apt-get -y install docker-ce
 
#    配置docker加速器(https://www.daocloud.io/mirror)(https://www.daocloud.io/mirror),下面的加速連結已做加密處理,請自行申請自己的加速連結
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://6c4b0j2a.m.daocloud.io
systemctl restart docker.service
 
#    測試docker是否安裝成功
echo  '\n-------------------------------------------------------------------------------\n\t\t\t執行 hello-world 測試Docker是否安裝成功\n-------------------------------------------------------------------------------\n\n'
docker run hello-world
 
 1 #!/bin/bash
 2  
 3 #    該指令碼基於 Ubuntu 16.04 64位 作業系統
 4  
 5 #    設定主機名
 6 echo 'docker-lab' >/etc/hostname
 7 hostname docker-lab
 8  
 9 #    配置Ubuntu源
10 cat >/etc/apt/sources.list << EOF
11 deb http://mirrors.aliyun.com/ubuntu/ xenial main
12 deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
13  
14 deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
15 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
16  
17 deb http://mirrors.aliyun.com/ubuntu/ xenial universe
18 deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
19 deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
20 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
21  
22 deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
23 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
24 deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
25 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
26 EOF
27  
28 #    配置docker源(使用阿里雲映象站)
29 apt-get -y install apt-transport-https ca-certificates curl software-properties-common
30 #curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
31 #add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
32 curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -
33 add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
34 apt-get update
35  
36 #    安裝docker
37 apt-get -y install docker-ce
38  
39 #    配置docker加速器(https://www.daocloud.io/mirror)(https://www.daocloud.io/mirror),下面的加速連結已做加密處理,請自行申請自己的加速連結
40 curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://6c4b0j2a.m.daocloud.io
41 systemctl restart docker.service
42  
43 #    測試docker是否安裝成功
44 echo  '\n-------------------------------------------------------------------------------\n\t\t\t執行 hello-world 測試Docker是否安裝成功\n-------------------------------------------------------------------------------\n\n'
45 docker run hello-world

 

相關文章