This is an old revision of the document!
orchestratorul de serviciiservicii
noduri
leader
--advertise-addr
$ docker swarm init --advertise-addr 192.168.99.100 Swarm initialized: current node (qtyx0t5z275wp46wibcznx8g5) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-4hd41nyin8kn1wx4bscnnt3e98xtlvyxw578qwxijw65jp1a3q-32rl6525xriofd5xmv0c1k5vj 192.168.99.100:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
node1node2
$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS qtyx0t5z275wp46wibcznx8g5 * node1 Ready Active Leader 0xbb9al1kuvn0jcapxiqni29z node2 Ready Active
orchestrare
[...] services: web: image: myimage deploy: replicas: 4 resources: limits: cpus: "0.2" memory: 50M restart_policy: condition: on-failure [...]
webmyimagewebMBweb
overlay
documentația oficialămy-web
$ docker secret create mysecret file.txt fm49ig0i8x9pdq0xxa8wdchoy
$ docker secret ls ID NAME DRIVER CREATED UPDATED fm49ig0i8x9pdq0xxa8wdchoy mysecret 3 seconds ago 3 seconds ago
my_stack.ymllab3
$ docker stack deploy -c my_stack.yml lab3
$ docker stack ps lab3 ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS cuktma92gm62 lab3_adminer.1 adminer:latest myvm2 Running Running 9 minutes ago njak2qzaobtt lab3_db.1 postgres:12 myvm1 Running Running 8 minutes ago m811buil7e63 lab3_io-service.1 mobylab/idp-laborator3-io:latest myvm1 Running Running 9 minutes ago jnfw37e34kz3 lab3_books-service.1 mobylab/idp-laborator3-books:latest myvm1 Running Running 9 minutes ago pzlzkgsxxc00 lab3_gateway.1 mobylab/idp-laborator3-gateway:latest myvm2 Running Running 9 minutes ago kpaahb931rbq lab3_io-service.2 mobylab/idp-laborator3-io:latest myvm1 Running Running 9 minutes ago num87yijgxrg lab3_books-service.2 mobylab/idp-laborator3-books:latest myvm2 Running Running 9 minutes ago d9m63k9h7ium lab3_gateway.2 mobylab/idp-laborator3-gateway:latest myvm1 Running Running 9 minutes ago lkmy60wpy0gv lab3_io-service.3 mobylab/idp-laborator3-io:latest myvm2 Running Running 9 minutes ago fy21iizn0reb lab3_gateway.3 mobylab/idp-laborator3-gateway:latest myvm2 Running Running 9 minutes ago
$ docker stack ls NAME SERVICES ORCHESTRATOR lab3 5 Swarm
$ docker service ls ID NAME MODE REPLICAS IMAGE PORTS dekzzyais8g7 lab3_adminer replicated 1/1 adminer:latest *:8080->8080/tcp 74y84hvq4irn lab3_books-service replicated 2/2 (max 1 per node) mobylab/idp-laborator3-books:latest ns9mxet1rkx5 lab3_db replicated 1/1 postgres:12 dh3sv3q74fy6 lab3_gateway replicated 3/3 (max 2 per node) mobylab/idp-laborator3-gateway:latest *:3000->80/tcp ru0rd7g2ypu8 lab3_io-service replicated 3/3 (max 2 per node) mobylab/idp-laborator3-io:latest
Docker MachinePlay with Docker
$ docker-machine create --driver virtualbox myvm1 Running pre-create checks... Creating machine... (myvm1) Copying /home/radu/.docker/machine/cache/boot2docker.iso to /home/radu/.docker/machine/machines/myvm1/boot2docker.iso... (myvm1) Creating VirtualBox VM... (myvm1) Creating SSH key... (myvm1) Starting the VM... (myvm1) Check network to re-create if needed... (myvm1) Waiting for an IP... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with boot2docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env myvm1
$ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS myvm1 - virtualbox Running tcp://192.168.99.100:2376 v17.09.0-ce
docker-machine ssh
$ docker-machine ssh myvm1 "ls -la"
docker-machine scp
$ docker-machine scp file.txt myvm1:.
$ docker-machine stop myvm1
$ docker-machine rm myvm1
$ docker service create --name <NUME_SERVICIU> <IMAGINE_DOCKER> # creează un serviciu pornind de la o imagine $ docker service ls # afișează toate serviciile din sistem $ docker service inspect <NUME_SERVICIU> # afișează informații despre un serviciu $ docker service logs –f <NUME_SERVICIU> # afișează log-urile unui serviciu $ docker service ps <NUME_SERVICIU> # afișează task-urile (și statusurile lor) pentru un serviciu $ docker service update --replicas <N> <NUME_SERVICIU> # actualizează serviciul, replicând containerele de N ori $ docker service rm <NUME_SERVICIU> # șterge un serviciu
$ docker node ls # afișează nodurile din cluster $ docker node promote <NUME_NOD> # promovează nodul din worker în manager $ docker node demote <NUME_NOD> # retrogradează nodul din manager în worker $ docker swarm init [--advertise-addr <IP>] # creează un cluster Docker $ docker swarm join --token <TOKEN> <IP> # se alătură unui cluster Docker
$ docker-machine create [--driver <DRIVER>] <NUME> # creează o mașină virtuală Docker $ docker-machine start <NUME> # pornește o mașină virtuală Docker $ docker-machine stop <NUME> # oprește o mașină virtuală Docker $ docker-machine rm <NUME> # șterge o mașină virtuală Docker $ docker-machine ls # listează toate mașinile virtuale Docker $ docker-machine ssh <NUME> # se conectează prin SSH la o mașină virtuală Docker $ docker-machine scp <FISIER> <NUME>:<DESTINATIE> # copiază un fișier pe o mașină virtuală Docker
laboratorul 2repository-ul oficial IDP
gatewayadminergatewayadminer
{"title": "Harry Potter and the Prisoner of Azkaban", "author": "J.K. Rowling", "genre": "Fantasy"}
io-servicedb_FILE