天天看點

ECS進階訓練營D2_搭建docker部署docker運作腳本拉取并運作nginx容器

部署docker

編寫快速部署腳本

tee docker_install.sh << -'EOF'
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://nulna16r.mirror.aliyuncs.com"] 
}
EOF
systemctl daemon-reload
systemctl restart docker
EOF           

運作腳本

bash docker_install.sh           

查詢docker運作狀态

systectl status docker
docker info           

拉取并運作nginx容器

編寫腳本

tee nginx_run.sh >> -'EOF'
docker pull nginx
docker run --name nginx-test -p 8080:80 -d nginx
EOF           
bash nginx_run.sh           

檢視nginx首頁

curl -L 127.0.0.1:8080

有nginx首頁說明部署成功