From 6c1958e244e22e0ece0f063bc0a5db9064ccb001 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Sat, 13 Feb 2016 10:56:55 -0800 Subject: [PATCH] Update Compose+Swarm section --- www/htdocs/index.html | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/www/htdocs/index.html b/www/htdocs/index.html index ce6d76f1..a31fa92c 100644 --- a/www/htdocs/index.html +++ b/www/htdocs/index.html @@ -121,7 +121,9 @@ class: title --- - + ## Outline (1/2) @@ -2742,7 +2744,7 @@ Before trying to build our app, we will remove previous images. ``` docker images | grep dockercoins | - awk '{print $3}' | + awk '{print $1}' | xargs -r docker rmi -f ``` @@ -2752,19 +2754,18 @@ Before trying to build our app, we will remove previous images. ## Building our app on Swarm -- Swarm has partial support for builds - -- .icon[![Warning](warning.png)] Older versions of Compose would crash on builds +- Compose now supports builds on Swarm +
(older versions would crash) .exercise[ -- Run `docker-compose build` multiple times -
(until you get it to build twice) +- Run `docker-compose build` -- Loudly complain that caching doesn't work as expected! - -- Run one container multiple times with a resource limit: -
`docker run -d -m 1G dockercoins_rng` +- Scale a few containers: + ``` + docker-compose scale worker=10 + docker-compose scale webui=2 + ``` - Check where the containers are running with `docker ps` @@ -2774,19 +2775,22 @@ Before trying to build our app, we will remove previous images. ## Caveats when building with Swarm -- Caching doesn't work all the time - - - cause: build nodes can be picked randomly - - - solution: always pin builds to the same node - -- Containers are only scheduled on a few nodes +- Containers are only scheduled where they were built - cause: images are not present on all nodes - solution: distribute images through a registry
(e.g. Docker Hub) +- You can end up with inconsistent versions +
(i.e. `dockercoins_rng:latest` being different on two nodes) + + - cause: build nodes can come and go + + - solution: always pin builds to the same node + +- Also, caching doesn't work all the time + --- ## Why can't Swarm do this automatically for us?