Docker Compose

In this section we will cover how to deploy a NEO•ONE Node to a swarm using Docker Compose.

If you haven’t already be sure to check out the local docker development section to familiarize yourself with the container we are deploying. Additionally, brushing up on Docker-Compose would also be worthwhile.


Getting Started

We’ll be deploying with docker-compose using swarm mode. The docker-compose.yml below is a very similar deployment to what we saw in the kubernetes section. We create a persistent named-volume for each container started and run our backup and sync configuration.

## docker-compose.yml
version: "3.1"
services:
  node:
    image: neoonesuite/node
    command: [
      "--node.rpcURLs=http://seed6.ngd.network:10332",
      "--node.rpcURLs=https://seed1.red4sec.com:10332"
    ]
    deploy:
      replicas: 1
      resources:
        limits:
          cpus: "1"
          memory: 4G
      restart_policy:
        condition: on-failure
    volumes:
      - node-data:/root/.local/share/neo-one
volumes:
  node-data:

To start a docker swarm and apply our deployment you can run

docker swarm init
docker stack deploy -c docker-compose.yml test

You can then check this service is running with

docker service ls

Finally, to shutdown this deployment kill the swarm using

docker swarm leave --force

Note

If you delete the service created by docker, you will still need to cleanup the volume, node-data in our example, that is created on startup. You can find the volume using docker volume ls and remove it using docker volume rm <volume-name>.

Logs

You can list all of the containers being run using

docker container ls

then to see its logs you can either attach directly to the container (we recommend this only for testing startup as SIGINT will kill the container) with

docker attach <container_id>

or check its most recent logs

docker logs <container_id>

Health Checks

You can add health checks to a docker swarm similar to a kubernetes setup. After enabling live checks in the NEO•ONE Node configuration we can enable a probe by adding the following to our compose configuration:

healthcheck:
  test: ['CMD', 'curl', '-f', 'http://localhost:<node-port>/live_health_check']
  interval: 1m30s
  timeout: 10s
  retries: 3
  start_period: 45s

See docker documentation for more information about health check configurations.

Edit this page
  • Local Docker Development
  • Kubernetes
  • Docker Compose
  • Building From Source
  • Heroku Deployment
  • Configuration Reference
Previous Article
Kubernetes
Next Article
Building From Source
DOCS
InstallationMain ConceptsAdvanced GuidesAPI ReferenceContributing
CHANNELS
GitHubStack OverflowDiscord ChatTwitterYouTube
COPYRIGHT © 2021 NEO•ONE