[Docker] Docker Swarm於 Ubuntu 16.04 建置以及操作流程
此紀錄安裝以及建置過程:
創建服務並部署至Cluster,以Nginx為例
1. 兩台以上的Ubuntu 16.04
- manager 192.168.80.1
- worker01 192.168.80.2
- sudo vim /etc/hosts
- 192.168.80.1 manager
- 192.168.80.2 worker01
於此步驟在所有主機上安裝Docker-ce Community Edition,使用以下命令安裝Docker-ce相關依賴套件
- sudo apt install apt-transport-https software-properties-common ca-certificates -y
- curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
- cd /etc/apt/sources.list.d
- sudo vim docker.list
- deb https://download.docker.com/linux/ubuntu zesty edge
- sudo apt update
- sudo apt install docker-ce
- sudo docker run hello-world
- systemctl start docker
- systemctl enable docker
- useradd -m -s /bin/bash user01
- sudo usermod -aG docker user01
- sudo su - user01
- docker run hello-world
- docker swarm init --advertise-addr 192.168.80.1
- docker swarm join --token SWMTKN-1-xxxxxxxxxxxxx-xxxxxxxx192.168.80.1:2377
- docker node ls
創建服務並部署至Cluster,以Nginx為例
- docker service create --name my-web --publish 8080:80 nginx:1.13-alpine
- docker service ls
- docker service scale my-web=2
- docker service ls
最後可以在網頁上輸入網址即可看到Nginx的畫面
- 192.168.80.1:8080
- 192.168.80.2:8080
留言
張貼留言