Shortened URL to access this gist: http://tiny.cc/swarmgs
All scripts work in bash and should work in powershell except as noted
git clone https://gist.github.com/g0t4/1454ee7342d54aba5313ffc699d472ba local-folder
This script pulls the images we're using in this workshop so when you need them they're already local.
git clone https://github.com/g0t4/docker-swarm-mode-getting-started/ swarmgs
cd swarmgs
git checkout necode-2017
# install dotfiles that I'm accumulating for PWD:
./warmup/pwd-dotfiles/install.sh
docker-compose -f warmup/docker-compose.yml pull --parallel
add registry mirror to docker config (tray icon with DfW/DfM): http://172.20.1.170:5000 test connectivity: 172.20.1.170:5000/v2/_catalog
http://play-with-docker.com/ - cloud hosted on-demand Linux lab environments for free!
- You can spin up as many instances (nodes) as you want with docker installed. A session lasts 4 hours so this is great for one-off learning.
- There's a built-in load balancer so you can access the services you startup remotely via a convention based url based on instance IP and service port. It's best to spin up a web server to see how this work, the UI will published ports and generate the link for you. Here's an example url
http://pwd10_0_157_3-4000.host2.labs.play-with-docker.com/
for a service running on 10.0.157.3 port 4000. - Pre canned examples - training.play-with-docker.com - you can click to run pre-canned commands and inspect the environment, this is a great way to learn with pre-built content. Right now the links to connect to your app remotely don't generate properly so you'll have to guess them based on the links generated from play-with-docker.com
- https://github.com/play-with-docker
- Read more in the announcement post: https://blog.docker.com/2017/04/dockercon-2017-mobys-cool-hack-sessions/
- tmux cheatsheet, a good way to split the screen with PWD:
- execute
echo set-option -g default-shell /bin/bash > ~/.tmux.conf
to tell tmux to use bash shell so completions work for docker - shortcuts: https://gist.github.com/andreyvit/2921703 and http://view.dckr.info:8080/#16
- important shortcuts:
- split pane into two rows panes:
Ctrl b, "
- split pane into two columns panes:
Ctrl b, %
- switch panes with
Ctrl b, arrowkey
(left, right, up, down) - resize panes 1 row at a time with
Ctrl b, Ctrl arrowkey
(can keep hitting arrow key for more) - resize panes 5 rows at a time with
Ctrl b, Meta arrowkey
(meta is often esc) - kill pane:
Ctrl b, x
- display pane numbers:
Ctrl b, q
- switch panes with
- create new window:
Ctrl b, c
- move windows:
Ctrl b, n
(n - next, p - previous)
- move windows:
- execute
docker run --name docs -p 4000:4000 docs/docker.github.io
docker service create --name docs -p 4000:4000 docs/docker.github.io
docker run --rm -p 8081:80 httpd
docker service create --name apache -p 8081:80 httpd
docker run --rm -p 8081:80 nginx
docker service create --name nginx -p 8081:80 nginx
docker service create \
--name=viz \
--publish=8090:8080 \
--constraint=node.role==manager \
--mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
manomarks/visualizer
Create the stack "manually"
docker network create -d overlay --subnet 10.0.9.0/24 backend
docker service create --name balance -p 5000:3000 --network backend swarmgs/balance
docker service create --name customer --network backend swarmgs/customer
# open website http://IP:5000/balance/1 - it is broken!
docker service logs balance # shows CUSTOMER_API value
docker service update --env-add MYWEB_CUSTOMER_API=customer:3000 balance
https://github.com/g0t4/docker-swarm-mode-getting-started