Files
docker-scripts/README.md
T

36 lines
2.6 KiB
Markdown
Raw Normal View History

2018-01-07 14:03:46 +01:00
Scripts for Docker Swarm Administration
=======================================
2017-09-26 09:40:30 +00:00
2018-01-07 14:03:46 +01:00
All scripts are documentd. For more details on any script, just call it with option `--help`.
docker-prune
------------
Cleanup docker. Removes all docker container that are not running,
then removes all unused docker images. In docker and especially docker swarm, when a service is restarted, the terminated and no more used containers still remain. Also unused images are never removed, even though they are probably outdated.
By default, this script removes all terminted containers and all unused images, that are older than one day. You can easily install it into the daily cron job using option `--install`.
docker-template
---------------
To create docker swarm yaml files from a template file by filling in special values. I use it to quickly create a new wordpress service, since I run many wordpress pages. The template just sets the name the external port and automatically generates new strong passwords for the mysql database. This way, I setup a new wordpress instance within some seconds.
docker-deploy
-------------
Just deploys a docker swarm stack from a yaml compose file. It saves me some typing. It scans the file for the volume pathes and creates them if they do not exist yet. Instead of the two commands `mkdir -p /var/volumes/my-service` and `docker stack deploy --compose-file my-service.yaml my-service`, I have to type only `docker-deploy my-service`. Yes, I am lazy.
2026-09-30 15:30:47 +02:00
The deployment runs with `--with-registry-auth`, so the registry credentials of the machine you deploy from travel to the nodes with every task. Run `docker login` there first: without credentials every node pulls anonymously, and the registry counts those pulls per address.
2018-01-07 14:03:46 +01:00
docker-update
-------------
Script to update all or some images within declared in a yaml file. Use it to update the docker image of all or some services in your already deployed docker swarm stack.
2026-09-30 15:30:47 +02:00
With `--rotate-key` it writes the registry credentials of the machine you run it on into every service of the stack and leaves the images untouched. A service carries the credentials of the moment it was deployed, and a node uses them when it pulls, so after the token of the registry account has been rotated every service needs them once.
docker-build
------------
Script to be called from a directory with a Dockerfile to build the docker image. Tha name of the tag is derieved from environment variable `DOCKER_USER` and the path name. It automatically applies the options `--rm --force-rm`. As additional options, you can overwirte the image name as first parameter, and/or pass more `docker build` options.