Working with Docker Images and Containers - SpotScore/spotscore GitHub Wiki

For a comprehensive introduction and reference please read the official The Docker user guide.

This guide here gives some quick receipts for managing images and containers to run and check the state of SpotScore.

Prerequisites

  • When using Vagrant box, log in with vagrant ssh and change the current directory to /spotscore.
  • If you are on Linux, just change to your SpotScore directory root. All the commands might need sudo if you have not created the docker user to run the commands (optional for development purposes).

Run the containers (in the background):

  1. Run docker-compose up -d.
  2. The -d option runs the containers in detached mode which enables to run new commands after the containers have started. Otherwise it will keep open the stdin's of started containers.
  3. To check the result, run docker-compose ps. Column "State" should show "Up" for all the containers.

Stop all the containers

  1. Run docker-compose stop.
  2. This will stop all the running containers. This won't delete them (and you won't lose the provisioned data). Next time you start (up) the services, they are as they were at the time of stopping.
  3. To check the result, run docker-compose ps`. Column "State" should show "Exit" with some exit code for all the containers.

(Re)start all the containers

  1. Run either docker-compose start or docker-compose up -d.
  2. The start will not require -d to run in detached mode, so is more convenient to use.
  3. To check the result, run docker-compose ps. Column "State" should show "Up" for all the containers.

Start or stop only one existing container

  1. Lets assume the containers were already created by docker-compose up but no containers are running (are in stopped state).
  2. To start a single existing container, run docker start spotscore_postgis_1 for example to run the PostGIS container.
  3. To stop the same container, run docker stop spotscore_postgis_1.

Kill the existing containers (and create new volumes for data)

  1. Run docker-compose kill.
  2. This will remove the containers, but keep the Docker images and container volumes with data etc in Vagrant machine's /var/lib/docker/containers/{container_hash}/....

Delete all Docker images

  1. Make sure all the containers are stopped/killed first.
  2. Run docker rmi $(docker images -q).
  3. Now all Docker images are gone. Next time you start new containers the new images will be pulled from the Docker Hub. Sometimes this is useful if you are not sure you are using the latest or greatest ones.