Skip to main content



Check that Docker is running and was installed correctly:

docker info

docker run hello-world

See system usage:

docker system df

See resource statistics on a particular node (MEM, CPU IO):

docker stats

Swarm Commands

A Docker “Swarm” is a cluster of hosts/servers that can deploy containers that are all in the same network.

To initialize a swarm:

docker swarm init

Leave a swarm:

docker swarm leave --force

Show the command that allows a host to join the swarm:

docker swarm join-token manager|worker

Join an existing swarm:

docker swarm join <details from above command>

A node is a host/server participating in a Swarm.

List nodes in a Swarm:

docker node ls

Show configuration of a Node:

docker node inspect <self | node ID>

To see labels for a given node in JSON format:

docker node inspect <node id> --format '{{json .Spec.Labels }}'

See resource statistics on a particular node (MEM, CPU IO):

docker stats

Stack Commands

A docker “stack” is collection of services in a Docker Swarm cluster. Each cluster can have multiple stacks. In the Brainspace deployment, the name, by default, of the stack that runs the Brainspace services is ‘brainspace’. Other stacks could exist in this cluster, for example, if installing Portainer, there will be another stack named ‘Portainer’.

To list running stacks in the cluster:

docker stack ls 

Status of the Brainspace stack: 

docker stack ps brainspace --no-trunc (optional: don't truncate output)

-- which should show all services in the stack, the number of containers running, the state of each, and any errors present.

In some cases, it may make sense to completely remove the Brainspace stack, to recover from errors and clean up the Docker environment. As long as the Docker volumes (see below) are not removed as well, Postgres data, logs, etc. will remain intact after removing and recreating a stack.

Remove the Brainspace stack:

docker stack rm brainspace

Service Commands

A service is a set of a particular type of container, where each container in a service is typically running on a different node/host.

List services (across all hosts/nodes in a swarm):

docker service ls

Show configuration of a service:

docker service inspect <service name>

Show service logs:

docker service logs <service name>

Follow service logs (similar to tail):

docker service logs -f <service name>

To capture logs from a container/service to a file, example using the brains-app service:

docker service logs brainspace_brains-app>& ./brains-app.log

Restart a service:

docker service update <service name> --force

Stop the container, and let Docker Swarm restart it automatically:

docker stop <container name/id>

To remove a service, usually so it can be re-added with an updated configuration:

docker service rm <service name>

Then if you redeploy the stack using the “Upgrade” option, the service will be recreated with the new configuration.


Removing a service is the only way to effectively stop the service in Docker Swarm.

Container Commands

A container is a member of a Docker service that is running on a particular Docker host/node. Commands that deal with containers must be run on the host/node where the container is running.

List running containers on a particular host:

docker ps

List processes running in a container:

docker top <container ID|name>

Get a shell into the container: 

docker exec -it <container ID> bash

To run a container that had previously shut down, for example the batch-tools containers:

docker run -it --rm <image ID> bash || sh


Docker Volumes are where Docker stores persistent filesystem data. Filesystems inside of a container are temporary and will be deleted when the container restarts, unless that filesystem is a part of a Docker Volume.

Be careful when deleting volumes since that is where important data is stored, such as Postgres DB data, and logs.


If you delete an NFS volume, it will NOT delete the associated data contained in the NFS share.

List volumes on a host/node:

docker volume ls

Show volume details – useful for debugging NFS volume issues:

docker volume inspect <volume name> 

To delete all volumes on a host with the given string in the name:

docker volume rm $(docker volume ls -q | grep <stack name>)

(Use with caution)


List images on a host/node:

docker images

Clean up

It’s important to periodically clean up unused Docker components to prevent errors, improve performance, and free up disk space.

Remove unused Docker components (images, containers, volumes, networks, etc.)

docker system prune --force (optional)

Delete all Docker components.


Only use this after doing a complete uninstall of Brainspace.