Docker Services con docker-compose.
Docker-compose es una herramienta que permite definir y ejecutar una aplicación en multicontenedores. se requiere de un archivo YAML para configurar los servicios de la aplicación.
Es útil para trbajar en ambientes productivos, ambientación, desarrollo, pruebas, también en workflows con CI.
Características
- Permite multiples ambientes aislados en un solo host.
- Preserva los datos de volumenes de los contenedores al crearlos.
- Solo recrea los contenedores que tienen cambios.
- Variables y traslados de composición entre ambientes.
https://github.com/jalbertomr/DockerSampleApp.git
Crearemos un servicio con capacidad de escalamiento, partiendo de la app anterior, una simple página web. Necesitamos tener Docker-engine para instalar docker-compose
Instalamos docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
bext@bext-VPCF13WFX:~$ docker-compose --version docker-compose version 1.24.0, build 0aa59064
Creamos el archivo docker-compose.yml
version: "3"services: web: #remplazar username/repo:tag con el nombre y imagen #image: username/repo:tag image: jalbertomr/lab_1:python_app_1 deploy: replicas: 5 resources: limits: cpus: "0.1" memory: 50M restart_policy: condition: on-failure ports: - "5000:4000" networks: - webnet networks: webnet:Este archivo es sencible a los espacios del inicio
Nos aseguramos que este corriendo nuestro contenedor con la imagen de la parte2
bext@bext-VPCF13WFX:~$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bext@bext-VPCF13WFX:~$ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE jalbertomr/lab1 python_app_1 68e8339a3346 17 hours ago 131MB python_app latest 68e8339a3346 17 hours ago 131MB python 2.7-slim ca96bab3e2aa 11 days ago 120MB hello-world latest fce289e99eb9 5 months ago 1.84kB
Todos estos pasos que acontinuación se muestran, hasta antes de arrancar swarm, fue por que no podiamos correr el contenedor y consultar en el browser
por que no coincidian los puertos en el comando de linea para arrancar el contenedor de la imagen. sirvase de enseñanza.
bext@bext-VPCF13WFX:~$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9d1bc605753c jalbertomr/lab1:python_app_1 "python app.py" 50 seconds ago Exited (0) 30 seconds ago amazing_hopper bext@bext-VPCF13WFX:~$ docker rm 9d1bc605753c 9d1bc605753c bext@bext-VPCF13WFX:~$ docker run -d -p 4000:80 jalbertomr/lab1:python_app_1 eb29a767aaba75f6a371ebf34f13054ca6e2d433a465b03940253d65c267128e bext@bext-VPCF13WFX:~$ ld ld: no input files bext@bext-VPCF13WFX:~$ ls Desktop examples.desktop PycharmProjects 'VirtualBox VMs' DockerAppConfig Music snap Documents Pictures Templates Downloads Public Videos bext@bext-VPCF13WFX:~$ cd DockerAppConfig bext@bext-VPCF13WFX:~/DockerAppConfig$ ls DockerSampleApp flaskSimpleBlog bext@bext-VPCF13WFX:~/DockerAppConfig$ cd DockerSampleApp bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ ls app.py docker-compose.yml requirements.txt app.py.save Dockerfile testRedis.py bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ ls app.py docker-compose.yml requirements.txt app.py.save Dockerfile testRedis.py bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker run -p 4000:80 jalbertomr/lab1:python_app_1 docker: Error response from daemon: driver failed programming external connectivity on endpoint agitated_shirley (8e2c4c5bc68c48a7fddd455233d342c8a5a86650350020a182bac9cd31cdda1d): Bind for 0.0.0.0:4000 failed: port is already allocated. ERRO[0005] error waiting for container: context canceled bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ sudo netstat -nlp [sudo] password for bext: Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1502/redis-server 1 tcp 0 0 127.0.0.1:63342 0.0.0.0:* LISTEN 6560/java tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 891/systemd-resolve tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 969/cupsd tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN 6560/java tcp6 0 0 :::2377 :::* LISTEN 1778/dockerd tcp6 0 0 :::7946 :::* LISTEN 1778/dockerd tcp6 0 0 ::1:6379 :::* LISTEN 1502/redis-server 1 tcp6 0 0 ::1:631 :::* LISTEN 969/cupsd tcp6 0 0 :::4000 :::* LISTEN 9042/docker-proxy udp 0 0 127.0.0.53:53 0.0.0.0:* 891/systemd-resolve udp 0 0 0.0.0.0:68 0.0.0.0:* 3299/dhclient udp 0 0 0.0.0.0:631 0.0.0.0:* 1091/cups-browsed udp 0 0 0.0.0.0:4789 0.0.0.0:* - udp 0 0 0.0.0.0:5353 0.0.0.0:* 954/avahi-daemon: r udp 0 0 0.0.0.0:39284 0.0.0.0:* 954/avahi-daemon: r udp6 0 0 :::7946 :::* 1778/dockerd udp6 0 0 :::45062 :::* 954/avahi-daemon: r udp6 0 0 :::5353 :::* 954/avahi-daemon: r raw6 0 0 :::58 :::* 7 1055/NetworkManager Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ACC ] STREAM LISTENING 28696 1683/gnome-session- @/tmp/.ICE-unix/1683 unix 2 [ ACC ] SEQPACKET LISTENING 19633 1/init /run/udev/control unix 2 [ ACC ] STREAM LISTENING 33587 2675/systemd /run/user/1000/systemd/private unix 2 [ ACC ] STREAM LISTENING 24158 1602/systemd /run/user/121/systemd/private unix 2 [ ACC ] STREAM LISTENING 36902 2675/systemd /run/user/1000/gnupg/S.gpg-agent.extra unix 2 [ ACC ] STREAM LISTENING 24162 1602/systemd /run/user/121/gnupg/S.dirmngr unix 2 [ ACC ] STREAM LISTENING 36903 2675/systemd /run/user/1000/gnupg/S.gpg-agent.browser unix 2 [ ACC ] STREAM LISTENING 24163 1602/systemd /run/user/121/gnupg/S.gpg-agent unix 2 [ ACC ] STREAM LISTENING 36904 2675/systemd /run/user/1000/gnupg/S.gpg-agent.ssh unix 2 [ ACC ] STREAM LISTENING 24164 1602/systemd /run/user/121/gnupg/S.gpg-agent.extra unix 2 [ ACC ] STREAM LISTENING 36905 2675/systemd /run/user/1000/gnupg/S.gpg-agent unix 2 [ ACC ] STREAM LISTENING 24165 1602/systemd /run/user/121/bus unix 2 [ ACC ] STREAM LISTENING 36906 2675/systemd /run/user/1000/bus unix 2 [ ACC ] STREAM LISTENING 36907 2675/systemd /run/user/1000/gnupg/S.dirmngr unix 2 [ ACC ] STREAM LISTENING 24166 1602/systemd /run/user/121/pulse/native unix 2 [ ACC ] STREAM LISTENING 24167 1602/systemd /run/user/121/gnupg/S.gpg-agent.browser unix 2 [ ACC ] STREAM LISTENING 34415 2691/gnome-keyring- /run/user/1000/keyring/control unix 2 [ ACC ] STREAM LISTENING 24168 1602/systemd /run/user/121/gnupg/S.gpg-agent.ssh unix 2 [ ACC ] STREAM LISTENING 18223 1/init /run/avahi-daemon/socket unix 2 [ ACC ] STREAM LISTENING 18225 1/init /run/snapd.socket unix 2 [ ACC ] STREAM LISTENING 18227 1/init /run/snapd-snap.socket unix 2 [ ACC ] STREAM LISTENING 18229 1/init /run/cups/cups.sock unix 2 [ ACC ] STREAM LISTENING 28631 2691/gnome-keyring- /run/user/1000/keyring/pkcs11 unix 2 [ ACC ] STREAM LISTENING 25989 1692/gnome-shell /run/user/121/wayland-0 unix 2 [ ACC ] STREAM LISTENING 21924 946/irqbalance @irqbalance946.sock unix 2 [ ACC ] STREAM LISTENING 18241 1/init /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 28634 2691/gnome-keyring- /run/user/1000/keyring/ssh unix 2 [ ACC ] STREAM LISTENING 18243 1/init /run/uuidd/request unix 2 [ ACC ] STREAM LISTENING 18245 1/init /var/run/docker.sock unix 2 [ ACC ] STREAM LISTENING 18247 1/init /run/acpid.socket unix 2 [ ACC ] STREAM LISTENING 39019 2860/pulseaudio /run/user/1000/pulse/native unix 2 [ ACC ] STREAM LISTENING 34463 2713/gnome-session- @/tmp/.ICE-unix/2713 unix 2 [ ACC ] STREAM LISTENING 36940 2699/Xorg @/tmp/.X11-unix/X0 unix 2 [ ACC ] STREAM LISTENING 23267 1444/gdm3 @/tmp/dbus-WKqALdUH unix 2 [ ACC ] STREAM LISTENING 23268 1444/gdm3 @/tmp/dbus-C0SbWmrC unix 2 [ ACC ] STREAM LISTENING 19606 1/init /run/systemd/private unix 2 [ ACC ] STREAM LISTENING 24416 2155/ibus-daemon @/tmp/dbus-xTKE4SmV unix 2 [ ACC ] STREAM LISTENING 386988 9049/containerd-shi @/containerd-shim/moby/eb29a767aaba75f6a371ebf34f13054ca6e2d433a465b03940253d65c267128e/shim.sock@ unix 2 [ ACC ] STREAM LISTENING 19616 1/init /run/systemd/journal/stdout unix 2 [ ACC ] STREAM LISTENING 19628 1/init /run/systemd/fsck.progress unix 2 [ ACC ] STREAM LISTENING 370226 1778/dockerd /var/run/docker/swarm/control.sock unix 2 [ ACC ] STREAM LISTENING 34563 2953/ibus-daemon @/tmp/dbus-LOqfuadL unix 2 [ ACC ] STREAM LISTENING 28697 1683/gnome-session- /tmp/.ICE-unix/1683 unix 2 [ ACC ] STREAM LISTENING 27622 1739/Xwayland /tmp/.X11-unix/X1024 unix 2 [ ACC ] STREAM LISTENING 31384 1444/gdm3 @/tmp/dbus-T7qoTtKo unix 2 [ ACC ] STREAM LISTENING 36941 2699/Xorg /tmp/.X11-unix/X0 unix 2 [ ACC ] STREAM LISTENING 31480 2808/ssh-agent /tmp/ssh-iHV6l1GJNGMm/agent.2713 unix 2 [ ACC ] STREAM LISTENING 34464 2713/gnome-session- /tmp/.ICE-unix/2713 unix 2 [ ACC ] STREAM LISTENING 28681 1414/containerd /run/containerd/containerd.sock unix 2 [ ACC ] STREAM LISTENING 24258 1778/dockerd /var/run/docker/metrics.sock unix 2 [ ACC ] STREAM LISTENING 29020 1778/dockerd /run/docker/libnetwork/189e00d7b4f23aa7ef973875067207e429d387c45f19bd33da42bef4eeb49861.sock unix 2 [ ACC ] STREAM LISTENING 23269 1444/gdm3 @/tmp/dbus-Rn8Mf6fw unix 2 [ ACC ] STREAM LISTENING 35028 2816/dbus-daemon @/tmp/dbus-qF7wQ39Bvd unix 2 [ ACC ] STREAM LISTENING 25046 1756/dbus-daemon @/tmp/dbus-94qRaQGoLZ unix 2 [ ACC ] STREAM LISTENING 27621 1739/Xwayland @/tmp/.X11-unix/X1024 unix 2 [ ACC ] STREAM LISTENING 31383 1444/gdm3 @/tmp/dbus-8l3ddx6A unix 2 [ ACC ] STREAM LISTENING 23266 1444/gdm3 @/tmp/dbus-tbYR6e42 unix 2 [ ACC ] STREAM LISTENING 35595 1055/NetworkManager /run/NetworkManager/private-dhcp bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ea1849d79d7a jalbertomr/lab1:python_app_1 "python app.py" About a minute ago Created agitated_shirley eb29a767aaba jalbertomr/lab1:python_app_1 "python app.py" 7 minutes ago Up 7 minutes 4000/tcp, 0.0.0.0:4000->80/tcp upbeat_keller bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker rm $(docker ps -aq) ea1849d79d7a Error response from daemon: You cannot remove a running container eb29a767aaba75f6a371ebf34f13054ca6e2d433a465b03940253d65c267128e. Stop the container before attempting removal or force remove bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stop $(docker ps -aq) eb29a767aaba bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ sudo netstat -nlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1502/redis-server 1 tcp 0 0 127.0.0.1:63342 0.0.0.0:* LISTEN 6560/java tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 891/systemd-resolve tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 969/cupsd tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN 6560/java tcp6 0 0 :::2377 :::* LISTEN 1778/dockerd tcp6 0 0 :::7946 :::* LISTEN 1778/dockerd tcp6 0 0 ::1:6379 :::* LISTEN 1502/redis-server 1 tcp6 0 0 ::1:631 :::* LISTEN 969/cupsd udp 0 0 127.0.0.53:53 0.0.0.0:* 891/systemd-resolve udp 0 0 0.0.0.0:68 0.0.0.0:* 3299/dhclient udp 0 0 0.0.0.0:631 0.0.0.0:* 1091/cups-browsed udp 0 0 0.0.0.0:4789 0.0.0.0:* - udp 0 0 0.0.0.0:5353 0.0.0.0:* 954/avahi-daemon: r udp 0 0 0.0.0.0:39284 0.0.0.0:* 954/avahi-daemon: r udp6 0 0 :::7946 :::* 1778/dockerd udp6 0 0 :::45062 :::* 954/avahi-daemon: r udp6 0 0 :::5353 :::* 954/avahi-daemon: r raw6 0 0 :::58 :::* 7 1055/NetworkManager Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ACC ] STREAM LISTENING 28696 1683/gnome-session- @/tmp/.ICE-unix/1683 unix 2 [ ACC ] SEQPACKET LISTENING 19633 1/init /run/udev/control unix 2 [ ACC ] STREAM LISTENING 33587 2675/systemd /run/user/1000/systemd/private unix 2 [ ACC ] STREAM LISTENING 24158 1602/systemd /run/user/121/systemd/private unix 2 [ ACC ] STREAM LISTENING 36902 2675/systemd /run/user/1000/gnupg/S.gpg-agent.extra unix 2 [ ACC ] STREAM LISTENING 24162 1602/systemd /run/user/121/gnupg/S.dirmngr unix 2 [ ACC ] STREAM LISTENING 36903 2675/systemd /run/user/1000/gnupg/S.gpg-agent.browser unix 2 [ ACC ] STREAM LISTENING 24163 1602/systemd /run/user/121/gnupg/S.gpg-agent unix 2 [ ACC ] STREAM LISTENING 36904 2675/systemd /run/user/1000/gnupg/S.gpg-agent.ssh unix 2 [ ACC ] STREAM LISTENING 24164 1602/systemd /run/user/121/gnupg/S.gpg-agent.extra unix 2 [ ACC ] STREAM LISTENING 36905 2675/systemd /run/user/1000/gnupg/S.gpg-agent unix 2 [ ACC ] STREAM LISTENING 24165 1602/systemd /run/user/121/bus unix 2 [ ACC ] STREAM LISTENING 36906 2675/systemd /run/user/1000/bus unix 2 [ ACC ] STREAM LISTENING 36907 2675/systemd /run/user/1000/gnupg/S.dirmngr unix 2 [ ACC ] STREAM LISTENING 24166 1602/systemd /run/user/121/pulse/native unix 2 [ ACC ] STREAM LISTENING 24167 1602/systemd /run/user/121/gnupg/S.gpg-agent.browser unix 2 [ ACC ] STREAM LISTENING 34415 2691/gnome-keyring- /run/user/1000/keyring/control unix 2 [ ACC ] STREAM LISTENING 24168 1602/systemd /run/user/121/gnupg/S.gpg-agent.ssh unix 2 [ ACC ] STREAM LISTENING 18223 1/init /run/avahi-daemon/socket unix 2 [ ACC ] STREAM LISTENING 18225 1/init /run/snapd.socket unix 2 [ ACC ] STREAM LISTENING 18227 1/init /run/snapd-snap.socket unix 2 [ ACC ] STREAM LISTENING 18229 1/init /run/cups/cups.sock unix 2 [ ACC ] STREAM LISTENING 28631 2691/gnome-keyring- /run/user/1000/keyring/pkcs11 unix 2 [ ACC ] STREAM LISTENING 25989 1692/gnome-shell /run/user/121/wayland-0 unix 2 [ ACC ] STREAM LISTENING 21924 946/irqbalance @irqbalance946.sock unix 2 [ ACC ] STREAM LISTENING 18241 1/init /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 28634 2691/gnome-keyring- /run/user/1000/keyring/ssh unix 2 [ ACC ] STREAM LISTENING 18243 1/init /run/uuidd/request unix 2 [ ACC ] STREAM LISTENING 18245 1/init /var/run/docker.sock unix 2 [ ACC ] STREAM LISTENING 18247 1/init /run/acpid.socket unix 2 [ ACC ] STREAM LISTENING 39019 2860/pulseaudio /run/user/1000/pulse/native unix 2 [ ACC ] STREAM LISTENING 34463 2713/gnome-session- @/tmp/.ICE-unix/2713 unix 2 [ ACC ] STREAM LISTENING 36940 2699/Xorg @/tmp/.X11-unix/X0 unix 2 [ ACC ] STREAM LISTENING 23267 1444/gdm3 @/tmp/dbus-WKqALdUH unix 2 [ ACC ] STREAM LISTENING 23268 1444/gdm3 @/tmp/dbus-C0SbWmrC unix 2 [ ACC ] STREAM LISTENING 19606 1/init /run/systemd/private unix 2 [ ACC ] STREAM LISTENING 24416 2155/ibus-daemon @/tmp/dbus-xTKE4SmV unix 2 [ ACC ] STREAM LISTENING 19616 1/init /run/systemd/journal/stdout unix 2 [ ACC ] STREAM LISTENING 19628 1/init /run/systemd/fsck.progress unix 2 [ ACC ] STREAM LISTENING 370226 1778/dockerd /var/run/docker/swarm/control.sock unix 2 [ ACC ] STREAM LISTENING 34563 2953/ibus-daemon @/tmp/dbus-LOqfuadL unix 2 [ ACC ] STREAM LISTENING 28697 1683/gnome-session- /tmp/.ICE-unix/1683 unix 2 [ ACC ] STREAM LISTENING 27622 1739/Xwayland /tmp/.X11-unix/X1024 unix 2 [ ACC ] STREAM LISTENING 31384 1444/gdm3 @/tmp/dbus-T7qoTtKo unix 2 [ ACC ] STREAM LISTENING 36941 2699/Xorg /tmp/.X11-unix/X0 unix 2 [ ACC ] STREAM LISTENING 31480 2808/ssh-agent /tmp/ssh-iHV6l1GJNGMm/agent.2713 unix 2 [ ACC ] STREAM LISTENING 34464 2713/gnome-session- /tmp/.ICE-unix/2713 unix 2 [ ACC ] STREAM LISTENING 28681 1414/containerd /run/containerd/containerd.sock unix 2 [ ACC ] STREAM LISTENING 24258 1778/dockerd /var/run/docker/metrics.sock unix 2 [ ACC ] STREAM LISTENING 29020 1778/dockerd /run/docker/libnetwork/189e00d7b4f23aa7ef973875067207e429d387c45f19bd33da42bef4eeb49861.sock unix 2 [ ACC ] STREAM LISTENING 23269 1444/gdm3 @/tmp/dbus-Rn8Mf6fw unix 2 [ ACC ] STREAM LISTENING 35028 2816/dbus-daemon @/tmp/dbus-qF7wQ39Bvd unix 2 [ ACC ] STREAM LISTENING 25046 1756/dbus-daemon @/tmp/dbus-94qRaQGoLZ unix 2 [ ACC ] STREAM LISTENING 27621 1739/Xwayland @/tmp/.X11-unix/X1024 unix 2 [ ACC ] STREAM LISTENING 31383 1444/gdm3 @/tmp/dbus-8l3ddx6A unix 2 [ ACC ] STREAM LISTENING 23266 1444/gdm3 @/tmp/dbus-tbYR6e42 unix 2 [ ACC ] STREAM LISTENING 35595 1055/NetworkManager /run/NetworkManager/private-dhcp bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker run -p 4000:80 jalbertomr/lab1:python_app_1 * Serving Flask app "app" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://0.0.0.0:4000/ (Press CTRL+C to quit) ^C bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stop $(docker ps -aq) 5ade104848f0 eb29a767aaba bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker rm $(docker ps -aq) 5ade104848f0 eb29a767aaba bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker swarm leave --force Node left the swarm. bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ ls app.py app.py.save docker-compose.yml Dockerfile requirements.txt testRedis.py bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ python app.py * Serving Flask app "app" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://0.0.0.0:4000/ (Press CTRL+C to quit) 127.0.0.1 - - [22/Jun/2019 12:48:43] "GET / HTTP/1.1" 200 - ^Cbext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker run -d -p 4000:80 jalbertomr/lab1:python_app_1 fb85fa9bd047bfcaa334bf852a2a8be0e981defb35b9d2c53b561d700a00ae55 bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ curl http://localhost:4000 . curl: (56) Recv failure: Connection reset by peer curl: (6) Could not resolve host: bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ curl http://localhost:4000/ . curl: (56) Recv failure: Connection reset by peer curl: (6) Could not resolve host: bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fb85fa9bd047 jalbertomr/lab1:python_app_1 "python app.py" 51 seconds ago Up 47 seconds 4000/tcp, 0.0.0.0:4000->80/tcp focused_mccarthy bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fb85fa9bd047 jalbertomr/lab1:python_app_1 "python app.py" 2 minutes ago Up 2 minutes 4000/tcp, 0.0.0.0:4000->80/tcp focused_mccarthy bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stop $(docker ps -aq) fb85fa9bd047 bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker run -d -p 5000:4000 jalbertomr/lab1:python_app_1 2d160093dee00b12cca971ef2260d40f43285ea7a7926742d3d10b64a7979cca bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2d160093dee0 jalbertomr/lab1:python_app_1 "python app.py" 50 seconds ago Up 47 seconds 0.0.0.0:5000->4000/tcp hardcore_robinson bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ sudo netstat -nlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1502/redis-server 1 tcp 0 0 127.0.0.1:63342 0.0.0.0:* LISTEN 6560/java tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 891/systemd-resolve tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 969/cupsd tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN 6560/java tcp6 0 0 ::1:6379 :::* LISTEN 1502/redis-server 1 tcp6 0 0 ::1:631 :::* LISTEN 969/cupsd tcp6 0 0 :::5000 :::* LISTEN 10315/docker-proxy udp 0 0 127.0.0.53:53 0.0.0.0:* 891/systemd-resolve udp 0 0 0.0.0.0:68 0.0.0.0:* 3299/dhclient udp 0 0 0.0.0.0:631 0.0.0.0:* 1091/cups-browsed udp 0 0 0.0.0.0:5353 0.0.0.0:* 954/avahi-daemon: r udp 0 0 0.0.0.0:39284 0.0.0.0:* 954/avahi-daemon: r udp6 0 0 :::45062 :::* 954/avahi-daemon: r udp6 0 0 :::5353 :::* 954/avahi-daemon: r raw6 0 0 :::58 :::* 7 1055/NetworkManager Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ACC ] STREAM LISTENING 28696 1683/gnome-session- @/tmp/.ICE-unix/1683 unix 2 [ ACC ] SEQPACKET LISTENING 19633 1/init /run/udev/control unix 2 [ ACC ] STREAM LISTENING 33587 2675/systemd /run/user/1000/systemd/private unix 2 [ ACC ] STREAM LISTENING 24158 1602/systemd /run/user/121/systemd/private unix 2 [ ACC ] STREAM LISTENING 36902 2675/systemd /run/user/1000/gnupg/S.gpg-agent.extra unix 2 [ ACC ] STREAM LISTENING 24162 1602/systemd /run/user/121/gnupg/S.dirmngr unix 2 [ ACC ] STREAM LISTENING 36903 2675/systemd /run/user/1000/gnupg/S.gpg-agent.browser unix 2 [ ACC ] STREAM LISTENING 24163 1602/systemd /run/user/121/gnupg/S.gpg-agent unix 2 [ ACC ] STREAM LISTENING 36904 2675/systemd /run/user/1000/gnupg/S.gpg-agent.ssh unix 2 [ ACC ] STREAM LISTENING 24164 1602/systemd /run/user/121/gnupg/S.gpg-agent.extra unix 2 [ ACC ] STREAM LISTENING 36905 2675/systemd /run/user/1000/gnupg/S.gpg-agent unix 2 [ ACC ] STREAM LISTENING 24165 1602/systemd /run/user/121/bus unix 2 [ ACC ] STREAM LISTENING 36906 2675/systemd /run/user/1000/bus unix 2 [ ACC ] STREAM LISTENING 36907 2675/systemd /run/user/1000/gnupg/S.dirmngr unix 2 [ ACC ] STREAM LISTENING 24166 1602/systemd /run/user/121/pulse/native unix 2 [ ACC ] STREAM LISTENING 24167 1602/systemd /run/user/121/gnupg/S.gpg-agent.browser unix 2 [ ACC ] STREAM LISTENING 34415 2691/gnome-keyring- /run/user/1000/keyring/control unix 2 [ ACC ] STREAM LISTENING 24168 1602/systemd /run/user/121/gnupg/S.gpg-agent.ssh unix 2 [ ACC ] STREAM LISTENING 18223 1/init /run/avahi-daemon/socket unix 2 [ ACC ] STREAM LISTENING 18225 1/init /run/snapd.socket unix 2 [ ACC ] STREAM LISTENING 18227 1/init /run/snapd-snap.socket unix 2 [ ACC ] STREAM LISTENING 18229 1/init /run/cups/cups.sock unix 2 [ ACC ] STREAM LISTENING 28631 2691/gnome-keyring- /run/user/1000/keyring/pkcs11 unix 2 [ ACC ] STREAM LISTENING 25989 1692/gnome-shell /run/user/121/wayland-0 unix 2 [ ACC ] STREAM LISTENING 21924 946/irqbalance @irqbalance946.sock unix 2 [ ACC ] STREAM LISTENING 18241 1/init /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 28634 2691/gnome-keyring- /run/user/1000/keyring/ssh unix 2 [ ACC ] STREAM LISTENING 18243 1/init /run/uuidd/request unix 2 [ ACC ] STREAM LISTENING 18245 1/init /var/run/docker.sock unix 2 [ ACC ] STREAM LISTENING 18247 1/init /run/acpid.socket unix 2 [ ACC ] STREAM LISTENING 39019 2860/pulseaudio /run/user/1000/pulse/native unix 2 [ ACC ] STREAM LISTENING 34463 2713/gnome-session- @/tmp/.ICE-unix/2713 unix 2 [ ACC ] STREAM LISTENING 36940 2699/Xorg @/tmp/.X11-unix/X0 unix 2 [ ACC ] STREAM LISTENING 23267 1444/gdm3 @/tmp/dbus-WKqALdUH unix 2 [ ACC ] STREAM LISTENING 23268 1444/gdm3 @/tmp/dbus-C0SbWmrC unix 2 [ ACC ] STREAM LISTENING 19606 1/init /run/systemd/private unix 2 [ ACC ] STREAM LISTENING 24416 2155/ibus-daemon @/tmp/dbus-xTKE4SmV unix 2 [ ACC ] STREAM LISTENING 19616 1/init /run/systemd/journal/stdout unix 2 [ ACC ] STREAM LISTENING 19628 1/init /run/systemd/fsck.progress unix 2 [ ACC ] STREAM LISTENING 34563 2953/ibus-daemon @/tmp/dbus-LOqfuadL unix 2 [ ACC ] STREAM LISTENING 28697 1683/gnome-session- /tmp/.ICE-unix/1683 unix 2 [ ACC ] STREAM LISTENING 27622 1739/Xwayland /tmp/.X11-unix/X1024 unix 2 [ ACC ] STREAM LISTENING 31384 1444/gdm3 @/tmp/dbus-T7qoTtKo unix 2 [ ACC ] STREAM LISTENING 36941 2699/Xorg /tmp/.X11-unix/X0 unix 2 [ ACC ] STREAM LISTENING 31480 2808/ssh-agent /tmp/ssh-iHV6l1GJNGMm/agent.2713 unix 2 [ ACC ] STREAM LISTENING 34464 2713/gnome-session- /tmp/.ICE-unix/2713 unix 2 [ ACC ] STREAM LISTENING 28681 1414/containerd /run/containerd/containerd.sock unix 2 [ ACC ] STREAM LISTENING 428776 10323/containerd-sh @/containerd-shim/moby/2d160093dee00b12cca971ef2260d40f43285ea7a7926742d3d10b64a7979cca/shim.sock@ unix 2 [ ACC ] STREAM LISTENING 24258 1778/dockerd /var/run/docker/metrics.sock unix 2 [ ACC ] STREAM LISTENING 29020 1778/dockerd /run/docker/libnetwork/189e00d7b4f23aa7ef973875067207e429d387c45f19bd33da42bef4eeb49861.sock unix 2 [ ACC ] STREAM LISTENING 23269 1444/gdm3 @/tmp/dbus-Rn8Mf6fw unix 2 [ ACC ] STREAM LISTENING 35028 2816/dbus-daemon @/tmp/dbus-qF7wQ39Bvd unix 2 [ ACC ] STREAM LISTENING 25046 1756/dbus-daemon @/tmp/dbus-94qRaQGoLZ unix 2 [ ACC ] STREAM LISTENING 27621 1739/Xwayland @/tmp/.X11-unix/X1024 unix 2 [ ACC ] STREAM LISTENING 31383 1444/gdm3 @/tmp/dbus-8l3ddx6A unix 2 [ ACC ] STREAM LISTENING 23266 1444/gdm3 @/tmp/dbus-tbYR6e42 unix 2 [ ACC ] STREAM LISTENING 35595 1055/NetworkManager /run/NetworkManager/private-dhcp
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ curl http://localhost:5000
<h3>Hola variable entorno NAME=Mundito (env var definido en Dockerfile)!</h3><b>Hostname:</b> 2d160093dee0<br/><b>Visitas:</b> <i>No hay conexion con Redis, contador deshabilidado</i>
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$
Ya tenemos el contenedor arrancando.
Arrancamos swarm
bext@bext-VPCF13WFX:~$ docker swarm init Swarm initialized: current node (65c8c67m4ytxk1bm2oomuibbh) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-67s7du8bjy5lrtu433ap4hg6dx6lo7yp5gvcgz4r863h1otg0l-a1p85c0m8gpqm608dnnfkwn03 10.201.166.247:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions. bext@bext-VPCF13WFX:~$ docker swarm leave --force Node left the swarm. bext@bext-VPCF13WFX:~$ docker swarm init Swarm initialized: current node (kya3t9kbp92y0rb2v7w9hj4b8) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-0rswyotq8z4oq8abvsuk7xh5x82uog5mhutcafli6qyd7j9fb9-arz5xnkwp5ym67msvzvjl0r74 10.201.166.247:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions. bext@bext-VPCF13WFX:~$
Creamos el servicio, la applicación previa ahora balanceada en carga
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stack deploy -c docker-compose.yml miserviciolab Creating network miserviciolab_webnet Creating service miserviciolab_web bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$
Rascamos para consultar el status del servicio
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker service ls ID NAME MODE REPLICAS IMAGE PORTS busix3kviuyn miserviciolab_web replicated 0/5 jalbertomr/lab_1:python_app_1 *:5000->4000/tcp bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker service ls ID NAME MODE REPLICAS IMAGE PORTS busix3kviuyn miserviciolab_web replicated 0/5 jalbertomr/lab_1:python_app_1 *:5000->4000/tcp bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stack services miserviciolab ID NAME MODE REPLICAS IMAGE PORTS busix3kviuyn miserviciolab_web replicated 0/5 jalbertomr/lab_1:python_app_1 *:5000->4000/tcp
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker service ps miserviciolab_web ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS nosnhjyr0pw9 miserviciolab_web.1 jalbertomr/lab_1:python_app_1 Ready Pending less than a second ago 6i5f5c13zc3s \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected less than a second ago "No such image: jalbertomr/lab…" vf9oijr6y74o \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 7 seconds ago "No such image: jalbertomr/lab…" nv76rncrbjb8 \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 11 seconds ago "No such image: jalbertomr/lab…" plgnr6drk2b1 \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 17 seconds ago "No such image: jalbertomr/lab…" 882l5twzzabb miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 4 seconds ago t6gjw25ozmja \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 7 seconds ago "No such image: jalbertomr/lab…" qdqsduxwxzf9 \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 14 seconds ago "No such image: jalbertomr/lab…" w65vd4a6g2us \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 18 seconds ago "No such image: jalbertomr/lab…" yjd9r6zpbegp \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 24 seconds ago "No such image: jalbertomr/lab…" okv6aojih1y8 miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Preparing 1 second ago tcr78c0tp0jw \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 4 seconds ago "No such image: jalbertomr/lab…" m8wf3bd4nhxc \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 7 seconds ago "No such image: jalbertomr/lab…" za3styluekxu \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 14 seconds ago "No such image: jalbertomr/lab…" 0jvgw6c69b5b \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 20 seconds ago "No such image: jalbertomr/lab…" 668urt9w35s3 miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Preparing 2 seconds ago 6bdi1cbkwetl \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 4 seconds ago "No such image: jalbertomr/lab…" qovn5ehsgx93 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 10 seconds ago "No such image: jalbertomr/lab…" 4gje1zwtfdcv \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 13 seconds ago "No such image: jalbertomr/lab…" s4s7car9on4t \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 20 seconds ago "No such image: jalbertomr/lab…" q5kltjcng4f3 miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Assigned less than a second ago tqybbwvpywde \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 2 seconds ago "No such image: jalbertomr/lab…" hp99j7a1nha7 \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 6 seconds ago "No such image: jalbertomr/lab…" aiiywgrhdoqy \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 14 seconds ago "No such image: jalbertomr/lab…" qq3438j1byei \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 20 seconds ago "No such image: jalbertomr/lab…" bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2d160093dee0 jalbertomr/lab1:python_app_1 "python app.py" About an hour ago Up About an hour 0.0.0.0:5000->4000/tcp hardcore_robinson
Verificamos los procesos del servicio, al mismo tiempo estresamos el contenedor para que se observe que cambia la carga al pasar de ready a running los servicios. con un script que consulta la pagina
bext@bext-VPCF13WFX:~$ for i in {1..2000}; do; curl http://localhost:5000; done
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stack ps miserviciolab ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ve7dumnog6og miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Preparing less than a second ago kx4jj54bibog \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 4 seconds ago "No such image: jalbertomr/lab…" 3s662z7208n5 \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 7 seconds ago "No such image: jalbertomr/lab…" 6nk11tmgoo3k \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 16 seconds ago "No such image: jalbertomr/lab…" mvowystlhxjv \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 20 seconds ago "No such image: jalbertomr/lab…" t8qkqebfwuwf miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Rejected 2 seconds ago "No such image: jalbertomr/lab…" o0sjgz5vodsc \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 7 seconds ago "No such image: jalbertomr/lab…" ic784sk7896s \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 13 seconds ago "No such image: jalbertomr/lab…" y4rz8cj96cic \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 20 seconds ago "No such image: jalbertomr/lab…" uwcm5kcnp8g4 \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 24 seconds ago "No such image: jalbertomr/lab…" nyn249bxvqb1 miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Rejected 2 seconds ago "No such image: jalbertomr/lab…" uyksmq5fa6zn \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 7 seconds ago "No such image: jalbertomr/lab…" kxubcquq649m \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 14 seconds ago "No such image: jalbertomr/lab…" w02kzztwvgf9 \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 18 seconds ago "No such image: jalbertomr/lab…" sutibw6t3z9h \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 23 seconds ago "No such image: jalbertomr/lab…" jtpwnrzt2fkj miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Rejected 2 seconds ago "No such image: jalbertomr/lab…" zreba0dz8q2s \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 7 seconds ago "No such image: jalbertomr/lab…" nqywg7x40wm7 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 10 seconds ago "No such image: jalbertomr/lab…" nam5zbjejwua \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 17 seconds ago "No such image: jalbertomr/lab…" 5nkid7f5x5md \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 22 seconds ago "No such image: jalbertomr/lab…" o3lh55qmxyrn miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Assigned less than a second ago 2in0g4zj0w8g \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 1 second ago "No such image: jalbertomr/lab…" xxgf0lcmsll2 \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 6 seconds ago "No such image: jalbertomr/lab…" 2tk6vv9wzuzs \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 17 seconds ago "No such image: jalbertomr/lab…" prma83xa9r8b \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 21 seconds ago "No such image: jalbertomr/lab…" z0tj39goeinr \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 25 seconds ago "No such image: jalbertomr/lab…" bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stack ps miserviciolab ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS iwk98bti786p miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 5 seconds ago 4u7mghrwiu5d \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 8 seconds ago "No such image: jalbertomr/lab…" rhjrvrgwqfn1 \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" ve7dumnog6og \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 24 seconds ago "No such image: jalbertomr/lab…" kx4jj54bibog \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 31 seconds ago "No such image: jalbertomr/lab…" 4m8u7ys9xl7p miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Preparing less than a second ago tyktnd7f1b89 \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 6 seconds ago "No such image: jalbertomr/lab…" xn9fng7nqhiw \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 13 seconds ago "No such image: jalbertomr/lab…" rg2amhjn8b86 \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 22 seconds ago "No such image: jalbertomr/lab…" t8qkqebfwuwf \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 29 seconds ago "No such image: jalbertomr/lab…" fagmse2z7h7l miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Preparing less than a second ago se876bzqt3to \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 6 seconds ago "No such image: jalbertomr/lab…" lhuwi446plfn \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" dl9h1xjl1oxm \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 19 seconds ago "No such image: jalbertomr/lab…" nyn249bxvqb1 \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 28 seconds ago "No such image: jalbertomr/lab…" knpnrf3s9gxw miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Preparing less than a second ago 6zy5z6vefir1 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 6 seconds ago "No such image: jalbertomr/lab…" iie8unrsofv1 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" hwndwqm6y435 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 22 seconds ago "No such image: jalbertomr/lab…" jtpwnrzt2fkj \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 29 seconds ago "No such image: jalbertomr/lab…" 6eqj5aalnnbd miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Ready Accepted 1 second ago wqlfhr6n618t \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 5 seconds ago "No such image: jalbertomr/lab…" ejjbuz6zqd4n \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 11 seconds ago "No such image: jalbertomr/lab…" vbebqfvd5x7p \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" o3lh55qmxyrn \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 24 seconds ago "No such image: jalbertomr/lab…" bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stack ps miserviciolab ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS y709pip6zi5m miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 5 seconds ago 8puzmwlt6ouo \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 11 seconds ago "No such image: jalbertomr/lab…" wveu1v9o66dj \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 18 seconds ago "No such image: jalbertomr/lab…" rxt2ehh8t4kv \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 21 seconds ago "No such image: jalbertomr/lab…" j6u6k1kdbuuy \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 30 seconds ago "No such image: jalbertomr/lab…" eak1gx8abeg6 miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 5 seconds ago f1we1mfogtpt \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 9 seconds ago "No such image: jalbertomr/lab…" nue2reethg9g \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 17 seconds ago "No such image: jalbertomr/lab…" xyyhoa2cn3ib \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 21 seconds ago "No such image: jalbertomr/lab…" p1ia7zgembee \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 28 seconds ago "No such image: jalbertomr/lab…" a9s5vx1bx7cq miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 7 seconds ago l33h5m5dz63x \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 14 seconds ago "No such image: jalbertomr/lab…" 54npnl331pli \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 20 seconds ago "No such image: jalbertomr/lab…" 4v95rxpj4qv7 \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 30 seconds ago "No such image: jalbertomr/lab…" j0pe2exx44di \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 34 seconds ago "No such image: jalbertomr/lab…" k73gibnsvc00 miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 5 seconds ago gm66vuldeg17 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 12 seconds ago "No such image: jalbertomr/lab…" 2jfl3evwdhav \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 19 seconds ago "No such image: jalbertomr/lab…" u31xidcqew89 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 28 seconds ago "No such image: jalbertomr/lab…" 56eupazo0qo2 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 33 seconds ago "No such image: jalbertomr/lab…" dpo4lazxuntp miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 5 seconds ago ved9caepkdal \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 10 seconds ago "No such image: jalbertomr/lab…" c4kbx3lnyp1q \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" vml02qd0vaa5 \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 21 seconds ago "No such image: jalbertomr/lab…" 84666v7m538n \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$Vamos a escalar la aplicación, modificando el docker-compose.yml a replicas: 10, y volvemos a generar el servicio, este se actualizará.
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stack deploy -c docker-compose.yml miserviciolab Updating service miserviciolab_web (id: busix3kviuynyccoor3ipp9vv) image jalbertomr/lab_1:python_app_1 could not be accessed on a registry to record its digest. Each node will access jalbertomr/lab_1:python_app_1 independently, possibly leading to different nodes running different versions of the image. bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker service ls ID NAME MODE REPLICAS IMAGE PORTS busix3kviuyn miserviciolab_web replicated 0/10 jalbertomr/lab_1:python_app_1 *:5000->4000/tcp bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$
Vemos que ya esta preparado para 10 replicas.
xt@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stack ps miserviciolab ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS thesgvuff689 miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 8 seconds ago 3motg82c4imq \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" labnvtrgqt6h \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" fqsaq6413ot6 \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 36 seconds ago "No such image: jalbertomr/lab…" u7ntk6havlsw \_ miserviciolab_web.1 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected about a minute ago "No such image: jalbertomr/lab…" tlbp3d0f9sj6 miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing about a minute ago kb0l4j8rz1rq \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected about a minute ago "No such image: jalbertomr/lab…" 7y9wjhsv05q0 \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected about a minute ago "No such image: jalbertomr/lab…" bkd78g806hds \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected about a minute ago "No such image: jalbertomr/lab…" yflisew39gjl \_ miserviciolab_web.2 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected about a minute ago "No such image: jalbertomr/lab…" 7nd7f01q77l6 miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 9 seconds ago uoczvsygnrdm \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" wm9w8hjgvckb \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" p0tsqi055khf \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 39 seconds ago "No such image: jalbertomr/lab…" s0fq4f0z8kcf \_ miserviciolab_web.3 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 49 seconds ago "No such image: jalbertomr/lab…" qc0bpsvu9i1f miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 9 seconds ago r0q1o3da2fy1 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" vdlfcfxio2j9 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" lcq7ism2dw1i \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 35 seconds ago "No such image: jalbertomr/lab…" 7pgj30sfk160 \_ miserviciolab_web.4 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 52 seconds ago "No such image: jalbertomr/lab…" kn18y7rzkqnr miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 8 seconds ago smnptxo4v6wt \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 14 seconds ago "No such image: jalbertomr/lab…" lbsb4cb5zqov \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" 8bpc2f3oyqtm \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 36 seconds ago "No such image: jalbertomr/lab…" 1ymzkzf1r54d \_ miserviciolab_web.5 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected about a minute ago "No such image: jalbertomr/lab…" xyelnb2mtqbi miserviciolab_web.6 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 8 seconds ago jhdgydzz2k0r \_ miserviciolab_web.6 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 14 seconds ago "No such image: jalbertomr/lab…" joszw7s68mfw \_ miserviciolab_web.6 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" hu26oqf3xy2d \_ miserviciolab_web.6 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 36 seconds ago "No such image: jalbertomr/lab…" yu91cperfd1u \_ miserviciolab_web.6 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected about a minute ago "No such image: jalbertomr/lab…" s5xyqw2frxqj miserviciolab_web.7 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 9 seconds ago osb85zlxyp77 \_ miserviciolab_web.7 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" ltfw2k6k5kld \_ miserviciolab_web.7 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" vqvdrm3ok7ht \_ miserviciolab_web.7 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 35 seconds ago "No such image: jalbertomr/lab…" tutpfv50z6qk \_ miserviciolab_web.7 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected about a minute ago "No such image: jalbertomr/lab…" 2xfxkrkxbu9a miserviciolab_web.8 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 8 seconds ago zbwsk1dyllsb \_ miserviciolab_web.8 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" zauvdx0kixqh \_ miserviciolab_web.8 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" ms9341xw48po \_ miserviciolab_web.8 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 38 seconds ago "No such image: jalbertomr/lab…" 6v98vz8ucscj \_ miserviciolab_web.8 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 46 seconds ago "No such image: jalbertomr/lab…" jf55j7e9iyro miserviciolab_web.9 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 8 seconds ago xlryx1qojeh6 \_ miserviciolab_web.9 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" n3a0d0vjxub9 \_ miserviciolab_web.9 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" gpd1dvy0pc18 \_ miserviciolab_web.9 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 39 seconds ago "No such image: jalbertomr/lab…" l2pw13il0xrn \_ miserviciolab_web.9 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 52 seconds ago "No such image: jalbertomr/lab…" r70rvkxu8kpl miserviciolab_web.10 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Running Preparing 9 seconds ago p9lfv2mtv2s9 \_ miserviciolab_web.10 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 15 seconds ago "No such image: jalbertomr/lab…" tyf3bxjxijl4 \_ miserviciolab_web.10 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 27 seconds ago "No such image: jalbertomr/lab…" qq8yovhj06to \_ miserviciolab_web.10 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected 36 seconds ago "No such image: jalbertomr/lab…" 1ou231bl7uz0 \_ miserviciolab_web.10 jalbertomr/lab_1:python_app_1 bext-VPCF13WFX Shutdown Rejected about a minute ago "No such image: jalbertomr/lab…" bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$
Ahora bajamos el servicio, y salimos de swarm.
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker stack rm miserviciolab Removing service miserviciolab_web Removing network miserviciolab_webnet bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ docker swarm leave --force Node left the swarm. bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$
eot
No hay comentarios:
Publicar un comentario