It is a dirty script which basically helps me run and stop pre-defined containers on Euclid. It just uses subprocess
in Python to run the commands with the options pre-defined in CONTAINERS
dictionary. This script is actually port of docker-func
script which I wrote in Bash few months ago for the same thing. The point of this is so that I don't have to remember and type all the options that need to be specified for those containers.
names
function takes no arguments can returns a list of names of all the running containers. It gets the names from the docker ps
command and no third party module is involved in it.
start_cont
function takes a string with name of a predefined container as argument and it runs that container using all the predefined options specified in the CONTAINERS
list.
stop_cont
function takes a string with name of a predefined container as argument and it stops the container with -t 0
option. It do not remove the container though.
rem_cont
function takes a string with name of a predefined container as argument and it removes the container.
res_cont
function takes a string with name of a predefined container as argument and then calls stop_cont
, rem_cont
and start_cont
in that order with name as argument, effectively restarting the container.
doch
function when called without any arguments just returns a help message which lists, sub commands and predefined containers.
Each sub command can be called with any number of arguments and it calls the corresponding function in a loop each time with new argument until it exhausts the list of all arguments.