# Stop and Restart YouTrack

This page provides instructions for stopping and restarting a YouTrack Server installation. To prevent unexpected loss of data, you need to stop your YouTrack installation before performing any of the following updates:

* Changing the location of the YouTrack database or other application files.

* Modifying YouTrack properties or JVM options for your YouTrack server.

* Switching traffic from HTTP to HTTPS and vice versa.

* Upgrading your YouTrack installation.

## Stop a Docker container

> **Note:**
> 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.

To stop the YouTrack service gracefully, run the command:

Linux (Bash):

```CONSOLE
docker exec <containerId> stop
```

Windows (PowerShell):

```CONSOLE
docker exec <containerId> stop.cmd
```

```CONSOLE
docker exec <containerId> stop.cmd
```

For a graceful shutdown, you can also use the standard `docker kill` command:

```CONSOLE
docker kill --signal=SIGTERM <containerId>
```

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 shut down completely within that time period, the `SIGKILL` is sent to the kernel, immediately terminating the Hub process. 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:

```CONSOLE
docker stop -t 60 <containerId>
```

## Start YouTrack with a Docker Container

To run a YouTrack container, enter the following command:

> **Note:**
> 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.

Linux (Bash):

```CONSOLE
docker run -it --name youtrack-server-instance \
-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 \
jetbrains/youtrack:<version>
```

Windows (PowerShell):

```CONSOLE
docker run -it --name youtrack-server-instance `
-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 `
jetbrains/youtrack:<version>
```

Command attributes:

* `-it` a command-line flag that attaches both the input and output of the container to your terminal. This lets you see the output produced by the container as if it were running directly in your terminal. When the container starts, you will see the log messages generated during the initialization process as well. Pressing `Ctrl` + `C` while the terminal is attached to a container's output sends an interrupt signal to the container's running process. This is similar to how you would stop a regular process in your terminal. This command causes the container to shut down, so be cautious when using `Ctrl` + `C` in this context. If you want to detach the terminal from the container output without interrupting the processes running in it, press `Ctrl` + `P` followed by `Ctrl` + `Q`. For more details, please refer to the [the official docker documentation](https://docs.docker.com/engine/reference/commandline/attach/#extended-description).

* `--name hub-server-instance` this is an arbitrary name for the container. By default, Docker generates random and sometimes cryptic names for containers. Use the `--name` option to give your container a more meaningful and human-readable name that makes it easier to identify and manage.

* `-v <path to <name> directory>:/opt/hub/<name>` these options specify the location of the storage provisioned on the host machine and maps them to the corresponding `/opt/hub/<name>` directories inside the container.

* `-p <port on host>:8080` parameter that defines the port mapping. This tells the host machine to listen for traffic on the `<port on host>` port and propagate all traffic to port `8080` inside the container.

