Select Page

Lets spawn a few instances…

$ ./docker_spawn.sh
8800
$ ./docker_spawn.sh
8801
$ ./docker_spawn.sh
8802
$ ./docker_spawn.sh
8803

docker’s process tool shows the current running instances

$ docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                           NAMES
d47a69cd24f8        r301_insh:latest    sudo -u shiny /usr/b   42 seconds ago      Up 41 seconds       130.216.39.130:8803->3838/tcp   thirsty_nobel
e5dab7fc1036        r301_insh:latest    sudo -u shiny /usr/b   43 seconds ago      Up 43 seconds       130.216.39.130:8802->3838/tcp   sick_nobel
78a99fe322b6        r301_insh:latest    sudo -u shiny /usr/b   45 seconds ago      Up 45 seconds       130.216.39.130:8801->3838/tcp   insane_lovelace
20dbd5775b17        r301_insh:latest    sudo -u shiny /usr/b   47 seconds ago      Up 47 seconds       130.216.39.130:8800->3838/tcp   clever_turing

Each of these creates a file in a tracking directory. The number returned is an internal port on the host to which docker maps the interaction on port 3838 within the container used as the template.

$ ls -l /var/docker/running/
total 16
-rw-rw-r-- 1 scienceit scienceit 65 Jul 21 17:00 8800
-rw-rw-r-- 1 scienceit scienceit 65 Jul 21 17:00 8801
-rw-rw-r-- 1 scienceit scienceit 65 Jul 21 17:00 8802
-rw-rw-r-- 1 scienceit scienceit 65 Jul 21 17:00 8803

These files contain the id which can be used to interact with each instance.

$ cat /var/docker/running/8801
78a99fe322b63660b47d1c6828c3fea0d3de5d920015678613c14e9ca34cdd61

Retiring an instances involves specifying the “port”

$ ./docker_retire.sh 8802
Retired instance 'f265377d5a998e7cf7c81b0003ee3a4bbb9ba8a185ac10fbfdeaaf09144bb548' on port '8802'

You cannot retire an instance that does not have a corresponding file in /var/docker/running/

$ ./docker_retire.sh 8802
This instance is not running!

And once a port is freed up, the spawning script will use it again.

$ ./docker_spawn.sh
8802
Skip to toolbar