YouTrack Server
 
2025.1

Run Docker Container as a Service

Last modified: 07 February 2025

Docker recommends using their cross-platform built-in restart policy for running a container as a service. For this, configure your Docker service to start on system boot and add the --restart unless-stopped parameter to the docker run command that starts YouTrack.

If you want to start multiple services one after the other, including YouTrack, the restart policy won't work well. In such cases, it's better to use a process manager instead.

Specific instructions for setting up a restart policy vary by operating system. To make sure you see information that is relevant to your installation, select the tab that corresponds with the operating system used in your host environment.

Here's an example of how to run YouTrack container as a service on Linux with help of systemd.

To run the YouTrack container as a service on Linux with systemd

  1. Create a service descriptor file /etc/systemd/system/docker.youtrack.service:

    [Unit]
    Description=YouTrack Service
    After=docker.service
    Requires=docker.service
    
    [Service]
    TimeoutStartSec=0
    Restart=always
    ExecStartPre=-/usr/bin/docker exec %n stop
    ExecStartPre=-/usr/bin/docker rm %n
    ExecStartPre=/usr/bin/docker pull jetbrains/youtrack:<version>
    ExecStart=/usr/bin/docker run --rm --name %n \
    -v <path to data directory>:/opt/youtrack/data \
    -v <path to conf directory>:/opt/youtrack/conf \
    -v <path to logs directory>:/opt/youtrack/logs \
    -v <path to backups directory>:/opt/youtrack/backups \
    -p <port on host>:8080 \
    --stop-timeout 60 \
    jetbrains/youtrack:<version>
    ExecStop=/usr/bin/docker exec %n stop
    
    [Install]
    WantedBy=default.target
  2. Enable starting the service on system boot with the following command:

    systemctl enable docker.youtrack

You can also stop and start the service manually at any moment with the following commands, respectively:

sudo service docker.youtrack stop
sudo service docker.youtrack start