Asterisk Telegram -

8

Docker Swarm Ubuntu 16.04.

Docker Swarm Docker, Docker , Swarm. Docker Swarm , Docker .

 Docker Swarm

Docker Swarm:

:

sudo apt-get update -y && sudo apt-get upgrade -y 

. Docker. Docker Ubuntu 16.04, Docker :

sudo apt-get install apt-transport-https software-properties-common ca-certificates -y: 

GPG Docker:

wget https://download.docker.com/linux/ubuntu/gpg && sudo apt-key add gpg

Docker :

sudo echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable" >> /etc/apt/sources.list sudo apt-get update -y

Docker :

sudo apt-get install docker-ce -y

Docker :

sudo systemctl start docker && sudo systemctl enable docker

Docker root , sudo. docker sudo, Unix :

sudo groupadd docker && sudo usermod -aG docker dockeruser

, dockeruser.

sudo ufw allow 2376/tcp && sudo ufw allow 7946/udp && sudo ufw allow 7946/tcp && sudo ufw allow 80/tcp && sudo ufw allow 2377/tcp && sudo ufw allow 4789/udp 

,

sudo ufw reload && sudo ufw enable

:

sudo systemctl restart docker

Docker Swarm , IP-, :

docker swarm init --advertise-addr 192.168.0.103

:

Swarm initialized: current node (iwjtf6u951g7rpx6ugkty3ksa) is now a manager. 
To add a worker to this swarm, run the following command:
    docker swarm join --token SWMTKN-1-5p5f6p6tv1cmjzq9ntx3zmck9kpgt355qq0uaqoj2ple629dl4-5880qso8jio78djpx5mzbqcfu 192.168.0.103:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions. 

:

docker node ls

, :

ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
iwjtf6u951g7rpx6ugkty3ksa *   Manager-Node        Ready               Active              Leader

Docker Swarm Cluster :

 code> docker info

:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.09.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
 NodeID: iwjtf6u951g7rpx6ugkty3ksa
 Is Manager: true
 ClusterID: fo24c1dvp7ent771rhrjhplnu
 Managers: 1
 Nodes: 1
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 192.168.0.103
 Manager Addresses:
  192.168.0.103:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-45-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 992.5MiB
Name: Manager-Node
ID: R5H4:JL3F:OXVI:NLNY:76MV:5FJU:XMVM:SCJG:VIL5:ISG4:YSDZ:KUV4
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

, Swarm Cluster. swarm init , Swarm Cluster:

docker swarm join --token SWMTKN-1-5p5f6p6tv1cmjzq9ntx3zmck9kpgt355qq0uaqoj2ple629dl4-5880qso8jio78djpx5mzbqcfu 192.168.0.103:2377

:

This node joined a swarm as a worker. 

:

docker node ls

:

ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
iwjtf6u951g7rpx6ugkty3ksa *   Manager-Node        Ready               Active              Leader
snrfyhi8pcleagnbs08g6nnmp     Worker-Node         Ready               Active

Docker Swarm Cluster , - Docker Swarm Mode. -:

docker service create --name webserver -p 80:80 httpd

- Apache 80 , - Apache . :

docker service ls 

:

ID                  NAME
MODE                REPLICAS            IMAGE               PORTS
nnt7i1lipo0h        webserver           replicated          0/1                 apache:latest       *:80->80/tcp

- :

docker service scale webserver = 2

:

docker service ps webserver 

:

ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE                  ERROR               PORTS
7roily9zpjvq        webserver.1         httpd:latest        Worker-Node         Running             Preparing about a minute ago
r7nzo325cu73        webserver.2         httpd:latest        Manager-Node        Running             Preparing 58 seconds ago

- Apache . -:

- Apache . Docker Swarm . - , . Docker :

sudo systemctl stop docker 

- :

docker service ps webserver 

:

ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS
ia2qc8a5f5n4        webserver.1         httpd:latest        Manager-Node        Ready               Ready 1 second ago
7roily9zpjvq         \_ webserver.1     httpd:latest        Worker-Node         Shutdown            Running 15 seconds ago                       r7nzo325cu73        webserver.2         httpd:latest        Manager-Node        Running             Running 23 minutes ago

, Docker Swarm Ubuntu 16.04. .


?


: