Deploying Trains Server: Linux or Mac OS X

Deploy the Trains Server in Linux or Mac OS X using our prebuilt Docker image.

Trains on Docker Hub

For Trains docker images, including previous versions, see Trains in Docker Hub. However, pulling the Trains Docker image directly is not required. We provide a docker compose YAML file that does this for you. The docker compose file is included in the instructions on this page.


For Linux users only:

  • You must be logged in as a user with sudo privileges.
  • Use bash for all command-line instructions in this installation.


To launch your Trains Server on Linux or Mac OS X, do the following:

  1. Install Docker. The instructions depend upon your operating system:
  2. Verify the Docker CE installation. Execute the command:
    sudo docker run hello-world
    The expected is output is:
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    To generate this message, Docker took the following steps:
    1. The Docker client contacted the Docker daemon.
    2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64)
    3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
  3. For Linux, only, install docker-compose. Execute the following commands (for more information, see Install Docker Compose in the Docker documentation):
    sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
  4. Increase vm.max_map_count for Elasticsearch in Docker. Execute the following commands, depending upon your operating system:
    • Linux:
      echo "vm.max_map_count=262144" > /tmp/99-trains.conf
      sudo mv /tmp/99-trains.conf /etc/sysctl.d/99-trains.conf
      sudo sysctl -w vm.max_map_count=262144
      sudo service docker restart
    • Mac OS X:
      screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
      sysctl -w vm.max_map_count=262144
  5. Remove any previous installation of Trains Server.

    This clears all existing Trains SDK databases.

    sudo rm -R /opt/trains/
  6. Create local directories for the databases and storage.
    sudo mkdir -p /opt/trains/data/elastic
    sudo mkdir -p /opt/trains/data/mongo/db
    sudo mkdir -p /opt/trains/data/mongo/configdb
    sudo mkdir -p /opt/trains/data/redis
    sudo mkdir -p /opt/trains/logs
    sudo mkdir -p /opt/trains/config
    sudo mkdir -p /opt/trains/data/fileserver
  7. For Mac OS X, only, do the following:
    1. Open the Docker app.
    2. Select Preferences.
    3. On the File Sharing tab, add /opt/trains.

  8. Grant access to the Dockers, depending upon your operating system.
    • Linux:

      sudo chown -R 1000:1000 /opt/trains

    • Mac OS X:

      sudo chown -R $(whoami):staff /opt/trains

  9. Download the Trains Server docker-compose YAML file.

    cd /opt/trains
    curl -o docker-compose.yml

  10. Run docker-compose with the downloaded configuration file.

    sudo docker-compose -f docker-compose.yml up -d

    Your server is now running on http://localhost:8080.

Port mapping

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

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


For detailed instructions, see Trains Server in Linux or Mac OS X, see Upgrading Trains Server.

Next Step