Docker Symlink Wrapper

From Wiki-DB
Revision as of 15:34, 14 September 2020 by Pzimmermann (talk | contribs) (Created page with "== Overview == <tt>docker-symlink-wrapper.py</tt> is a wrapper script which creates symlinks for applications. If the symlink is called the script starts the corresoponding a...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Overview

docker-symlink-wrapper.py is a wrapper script which creates symlinks for applications. If the symlink is called the script starts the corresoponding application in a container and passes all parameters to it. The script can manage multiple symlinks which can point to different container images. It is also possible to set the tag of the docker image which is used (= version of the application).

docker-symlink-wrapper.py requires the python modules requests and docker. The versions supplied by the Debian package repository is, at least in stretch, too old (especially the docker module), so install the recent version via pip: pip3 install -r requirements.txt with using the requirements file supplied at this repository or pip3 install requests docker for directly installing the requirements.

The wrapper script uses a configuration file for storing the known symlink and their configration. This file is located at /var/lib/docker-symlink-wrapper/symlinks.json. This concludes that you need to superuser privileges if you want to call a command of the script which changes the configuration.

For authentification at docker registries the saved credentials of the Docker CLI are used (usually at ~/.docker/config.json). So use docker login <registry-address> to login into the registry before using the script.

Available Commands

  • docker-symlink-wrapper.py install <name> <json file>|- for installing new symlinks to a container and adding them to the configuration file of the script. 'name' is an unique keyword for the entry in the configuration file (so that the entry can be recognized later), while 'json file' is a file in the JSON format which has the configuration of the container (Definition of the fields of the JSON file is below).
  • docker-symlink-wrapper.py uninstall <name> for removing the symlinks from a container and removing them from the configuration of the script. 'name' is an unique keyword of the entry in the configuration file.
  • docker-symlink-wrapper.py list for listing all known symlinks, its keyword and the corresponding container.
  • docker-symlink-wrapper.py list-versions <name> lists all available versions of a container (= tag) for this 'name'. This command does connect to the corresponding container registry and reads the available tags. This command does NOT work with images which are only local! For using this command with registies which require the addition of certificates (like corporate internal registries) you have to add the certificate (or its root certificate) to the system certificates (usually at /etc/ssl/certs/ca-certificates.crt).
  • docker-symlink-wrapper.py set-version <name> <tag> sets the used version of the container for the 'name' to the 'tag',
  • <symlinkname> [...] When the script is called trough one of the symlinks, it looks at the configuration to determine the correct container to start. After that it starts that container and calls inside the container the applictaion which has the same name as the symlink and passes all parameter to it.