Docker

This section contains scripts related to Docker:

docker_build

build the image

docker_cleanup

remove all project-related containers, images, networks, and volumes

docker_health

query the health status of the container

docker_ignore_all

create a .dockerignore file ignoring everything

docker_inspect

display detailed information on the container

docker_logs

display the logs of the container

docker_remove

remove the container and associated unnamed volumes

docker_sh

open a shell into the running container

docker_start

start the image

docker_stop

stop the container

Usage

The scripts should be copied into a project, e.g.:

<project root directory>
├── Dockerfile
└── scripts
    ├── docker_build.sh
    ├── ...

And then invoked from the directory containing the Dockerfile:

$ scripts/docker_build.sh

All scripts need Docker to be installed.

You should modify the container_name, label_group, namespace, and repository shell variables in the copied scripts—​the values need to match in all scripts:

readonly container_name="sdavids-shell-misc-docker-example"
readonly label_group='de.sdavids.docker.group'
readonly namespace='de.sdavids'
readonly repository='sdavids-shell-misc'

The scripts expect the image to be named ${namespace}/${repository} having a label ${label_group}=${repository}.

The scripts expect the container to be named ${container_name}.

You can try the scripts with the example Dockerfile:

$ scripts/docker/docker_build.sh -d scripts/docker/Dockerfile
$ scripts/docker/docker_start.sh
$ scripts/docker/docker_logs.sh
$ scripts/docker/docker_health.sh
$ scripts/docker/docker_inspect.sh
$ scripts/docker/docker_sh.sh
$ scripts/docker/docker_stop.sh
$ scripts/docker/docker_remove.sh
$ scripts/docker/docker_cleanup.sh