Start and Stop Docker Container
This page describes how to stop and start your Hub server.
The following situations require that you stop your Hub server:
You want to change the location of the Hub database.
You want to modify Hub properties or JVM options for your Hub server.
You want to upgrade your Hub installation.
Run Hub docker container
To run Hub container, execute the command:
docker run -it --name hub-server-instance \ -v <path to data directory>:/opt/hub/data \ -v <path to conf directory>:/opt/hub/conf \ -v <path to logs directory>:/opt/hub/logs \ -v <path to backups directory>:/opt/hub/backups \ -p <port on host>:8080 \ jetbrains/hub:<version>
-it— a flag that attaches Hub container input and output including the startup logs to the terminal window. Note that pressing `Ctrl+C` when the terminal is attached to a container output causes the container to shut down. Use `Ctrl+PQ` in order to detach the terminal from container output. For more details, see the official docker documentation.
--name hub-server-instance— the arbitrary name for the container.
-v <path to NNN directory>:/opt/hub/NNN— binding the Hub-specific 'NNN' directory on the host machine to the respective
/opt/hub/NNNdirectory inside the container.
-p <port on host>:8080— parameter that defines the ports mapping. It instructs the host machine to listen on port
<port on host>and propagate all traffic to the port `8080` inside the docker container.
Stop Hub docker container
To stop the Hub service gracefully, run the command:
docker exec <containerId> stop
For a graceful shutdown, you can also use the standard `
docker kill --signal=SIGTERM <containerId>` command.
We do not recommend using the standard command `
docker stop`. By default, this command sends the `
SIGTERM` signal to the Hub process inside the Docker container, then waits for 10 seconds. If Hub does not finish the shutdown within that time period, the `
SIGKILL` is sent to the kernel and the Hub process is killed. This may lead to data corruption. To avoid this outcome, specify an appropriate timeout value when using this command. For example, the following command leaves enough time for the Hub service to shut down:
docker stop -t 60 <containerId>
Run Hub container as a service
Docker team recommends to use cross-platform built-in restart policy for running container as a service. For this, configure your docker service to start on system boot and simply add parameter
--restart unless-stopped to the
docker run command that starts Hub.
However, when it comes to the sequential start of several services (including Hub), the restart policy method will not suit. You can use a process manager instead.
Here's an example of how to run Hub container as a service on Linux with help of
To run Hub container as a service on Linux with systemd
Create a service descriptor file
[Unit] Description=Hub 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/hub:<version> ExecStart=/usr/bin/docker run --rm --name %n \ -v :/opt/hub/data \ -v :/opt/hub/conf \ -v :/opt/hub/logs \ -v :/opt/hub/backups \ -p :8080 \ jetbrains/hub:<version> [Install] WantedBy=default.target
Enable starting the service on system boot with the following command:
systemctl enable docker.hub
You can also stop and start the service manually at any moment with the following commands, respectively:
sudo service docker.hub stop sudo service docker.hub start