How Can We Help?

Search for answers or browse our knowledge base.


Still need help? Ask our Service Desk!

Categories
< All Topics
Print

How to manage a Docker node

Manage node

With Docker

This is only a short summary from the fantastic docs.docker.com documentation website. Please visit it for more indepth information.

Visualization

docker-compose bundles many services that are started together and interact together. In our case we have the services: GNY Blockchain Node (a node.js app) and a database (postgres) service. Each of this services is a separate docker container.

postgresdb GNY Blockchain

This two services are based off their respective docker images postgres:9.6.12 and gny/blockchain.

Docker Images

A docker image is like a cookie cutter which can cut cookies (instantiate containers). From one image we can create exactly the same program, without the need to install or provide all libraries a program depends upon.

docker-db-image docker-node-image

From an image we can create multiple containers.

docker-db-image-multiple-instances docker-node-image-multiple-instances

Docker networks

docker-compose creates automatically a network where only the services inside the docker-compose file can communicate. This is represented by the grey box. We can configure which service ports from the containers are visible on the host machine. The postgres database port is not reachable from the host machine. Only the GNY Blockchain service can access the postgres database service. The GNY Blockchain ports (4096 and 4097) are mapped to the host machine.

This is the beauty of docker-compose. We can specify all services that should work together and with one command we can start|stop|pause all services.

Docker-Compose Lifecycle

Docker-Compose 101

Create and Start all services

sudo docker-compose --file docker-compose.yml up

This command will print all container messages to screen:
docker_compose_up_console_output

Create and Start all services

sudo docker-compose --file docker-compose.yml up --detach

This command runs all services in background. See logs command to see the logs of the services in the background.

docker_compose_up_console_background

Start all services

This can only be executed if the docker-compose network and all containers were created previously. For example after an docker-compose stop.

sudo docker-compose --file docker-compose.yml start

docker_compose_start_error

docker_compose_start_success

Check status of services

sudo docker-compose --file docker-compose.yml ps

docker_compose_ps

Stop all services

sudo docker-compose --file docker-compose.yml stop

docker_compose_stop

Stop and Remove

This removes the docker-compose network and volumes that were created.

sudo docker-compose --file docker-compose.yml down --volumes

Docker 101

Images

Show all images

sudo docker image ls

Get bash into image

sudo docker run -it <imageId> /bin/bash

Containers

Show status of running containers

sudo docker ps --all

Show status of containers of a docker-compose file

sudo docker-compose --file docker-compose.yml ps

Bash into running container

sudo docker exec -it <containerId> /bin/bash

Delete

Stop all running containers

sudo docker stop $(sudo docker ps --all --quiet)

Delete all stopped containers

sudo docker rm $(sudo docker ps --all --quiet)

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Previous How to configure a Docker node
Next How to start a Docker GNY node
Table of Contents