Deploying Trains Server: Google Cloud Platform

Deploy Trains Server on the Google Cloud Platform (GCP) using use one of our pre-built GCP Custom Images. Trains provides custom images for each released version of Trains Server. For a list of our pre-built custom images, see Released versions.

After deploying Trains Server, configure the Trains Python Client for it, see Configuring Trains for Trains Server.

Default Trains Server service ports

After deploying Trains Server, the services expose the following node ports:

  • Web server on 8080.
  • API server on 8008.
  • File Server on 8081.

Default Trains Server storage paths

The persistent storage configuration:

  • MongoDB: /opt/trains/data/mongo/
  • Elasticsearch: /opt/trains/data/elastic/
  • File Server: /mnt/fileserver/

Importing the Custom Image to your GCP account

Before launching an instance using a Trains Server GCP Custom Image, import the image to your custom images list.

No upload of the image file is required

We provide links to image files stored in Google Storage.

To import the image to your custom images list:

  1. In the Cloud Console, go to the Images page.
  2. At the top of the page, click Create image.
  3. In Name, specify a unique name for the image.
  4. Optionally, specify an image family for your new image, or configure specific encryption settings for the image.
  5. In the Source menu, select Cloud Storage file.
  6. Enter the Trains Server image bucket path (see Released versions), for example: allegro-files/trains-server/trains-server.tar.gz
  7. Click Create to import the image. The process can take several minutes depending on the size of the boot disk image.

For more information see Import the image to your custom images list in the Compute Engine Documentation.


Securing deployment

By default, Trains Server deploys as an open network. To restrict Trains Server access, follow the instructions in the Securing deployment section, on the "Configuring Trains Server" page.

To launch Trains Server using a GCP Custom Image, see the Manually importing virtual disks in the "Google Cloud Storage" documentation, Compute Engine documentation. For more information on Custom Images, see Custom Images in the "Compute Engine documentation".

The minimum requirements for Trains Server are:

  • 2 vCPUs
  • 7.5GB RAM

Network and security

Ensure your instance is properly secured. If not specifically set, a GCP instance will use default firewall rules that allow public access to various ports. If your instance is open for public access, we recommend that you follow best practices for access management, including:


To restart your Trains Server Docker deployment:

  • To restart Trains Server, first stop and then restart the Docker containers by executing the following commands:
    docker-compose -f /opt/trains/docker-compose.yml down
    docker-compose -f /opt/trains/docker-compose.yml up -d


To upgrade your Trains Server Docker deployment:

  1. Shut down the docker containers. Execute the following command:
    docker-compose -f docker-compose.yml down
  2. We recommend backing up your data and, if your configuration folder is not empty, backing up your configuration.

    For example:

    If your data and configuration folders are in /opt/trains, then archive all data into ~/trains_backup_data.tgz, and your configuration into ~/trains_backup_config.tgz:

    • backup your data and configuration.
      sudo tar czvf ~/trains_backup_data.tgz -C /opt/trains/data .
      sudo tar czvf ~/trains_backup_config.tgz -C /opt/trains/config .
    • restore your data and configuration.
      sudo rm -fR /opt/trains/data/* /opt/trains/config/*
      sudo tar -xzf ~/trains_backup_data.tgz -C /opt/trains/data
      sudo tar -xzf ~/trains_backup_config.tgz -C /opt/trains/config
  3. Download the latest docker-compose.yml file.
    curl -o /opt/trains/docker-compose.yml
  4. Spin up the docker containers. This automatically pulls the latest Trains Server build.
    docker-compose -f /opt/trains/docker-compose.yml pull
    docker-compose -f /opt/trains/docker-compose.yml up -d

If issues arise during your upgrade, see the FAQ page, How do I fix Docker upgrade errors?.

Examples and use cases

For examples and use cases, see the Examples page in this User Guide documentation, and the examples folder of the trains repository.

Released versions

The following a section contains a list of Custom Image URLs (exported in different formats) for each released Trains Server version.

Latest version - v0.15

All release versions

Next Step