Package: robotframework-dockerlibrary
DockerLibraryLibrary version:1.0Library scope:DockerIntroductionA library providing keywords for handling docker.DockerLibrary is Robot Framework's library that provides a set of keywords for handling docker. This library support all Docker CLI(docker) commands and options to work with docker. Furthermore, It provides handling multiple containers and also phenomenon called "docker in docker". The last extra feature is class DotDictionary which makes it easier to work with the output of basic Docker CLI commands.Table of contentsDocker CLI(docker)Multiple Docker containersDocker in DockerDotDictionary and parse commandsDocker CLI(docker)The basicdocker (base command)takes this form:docker | <base command> | [OPTIONS]Example:docker  run  --name  test  -dt  ubuntuMultiple Docker containersKeywords for handling multiple conatiners at once.Create multiple containersKeywords for creating multiple containers with one command.Returns:List[str], where strings are containers ids which were createdcreate multiple containers | <number of containers> | <name of image>Example:create multiple containers  3  ubuntuDocker command for all containersKeywords for executing basic Docker CLI commands for multiple containers at once.Returns:if parameter <parse to dotd> is true: Dict[str, DotDictionary], where keys are containers ids and values are outputs from command execution converted to DotDictionaryif parameter <parse to dotd> is false: Dict[str, str], where keys are containers ids and values are strings outputs from command executiondocker command for all | <containers ids> | <parse to dotd> | <base command> | [OPTIONS]Example:${containers_id} =  docker  ps  -a  -q
docker command for all  ${containers_id.stdout}  False  rm  -fDocker in DockerKeyword for handling docker in docker.docker in dockerRuns host docker in docker using default Unix socket/var/run/docker.sockand then it creates multiple containers of given imageThere are three options for docker in docker host:UbuntuAlpineCentosReturns:Dict[str, List[str]], where key is host container id and value is list of containers ids which where createddocker in docker | alpine/ubuntu/centos | <custom image> | <number of containers to create>Example:docker in docker  alpine  ubuntu  5Parse commandsKeywords that helps to parse outputs from docker.Parse docker responseIf parameter <parse to dotd> is set True, It will try to parse the output given to DotDictionary and if it fails it returns string.
If parameter <parse to dotd> is set False. It will remove all whitespace characters from string given and return that string.Returns:DotDictionary or List[DotDictionary] or stringDotDictionary is a class for easier working with output of docker commands.Example of using DotDictionary:${containers_id} =  docker  ps  -a  -q
${dictionary} =  docker command for all  ${containers_id.stdout}  True  inspect
${values} =  Get Dictionary Values  ${dictionary}
Log  ${values[0].Config.Entrypoint}Returns:DotDictionary or List[DotDictionary] or stringparse docker response | <response> | <parse to dotd>Example:${parsed_to_dotd_output} =  parse docker response  ${result.stdout}  Trueget containers idsKeyword to get containers ids.Returns:List[str], where strings are container idsget containers idsExample:${containers_ids} =  get containers ids