# Update within a Docker container

{% tabs %}
{% tab title="Windows (Docker Desktop)" %}

## Replacing the agent

{% hint style="danger" %}
The only way to update an agent installed in a container is to **remove the existing version and create a new one**.
{% endhint %}

1. Download the new image and remove the old container with the agent using the following command:

```dockerfile
docker pull xopero/gitprotect-agent:latest
docker stop xopero-agent && docker rm xopero-agent
```

2. Create a new container with the **GitProtect worker**:

```dockerfile
docker run -d \
  --name xopero-agent \
  -e ManagementServiceUrl="<your_xopero_service_URL>" \
  -e XoperoOverriddenHostName="<device_name>" \
  -v /opt/gitprotect-agent/data:/app/Xopero \
  --restart unless-stopped \
  xopero/gitprotect-agent:latest
```

* `<your_xopero_service_URL>` — **GitProtect Management Service** address with the port (i.e., `123.456.7.890:28555`)
* `<device_name>` — custom **Docker** container name

3. Once done, the **GitProtect worker** should now be up to date.
   {% endtab %}

{% tab title="QNAP NAS (CS > 3.0)" %}
{% hint style="warning" %}
This method requires **Container Station version 3.0 or later**.
{% endhint %}

## Update process

1. First, open **Container Station** on your **QNAP** device.
2. Locate and select the container running the **worker** you want to update, then click the **settings** ⚙️ icon to open the container settings.
3. In the settings menu, select the **Recreate** option to proceed with the update. This action replaces the current container with a new one based on the latest image.

<figure><img src="https://696332517-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtsE6XtJyUIEKVdSxPlS3%2Fuploads%2FnXwyV28XHRJPGJnOkv3V%2Fagentdocker1.png?alt=media&#x26;token=58c1163c-d0b4-4858-bb92-1e2b1d5aee12" alt="" width="170"><figcaption></figcaption></figure>

4. Switch to **Advanced mode** (see illustration below). You will be prompted for the **Docker Hub** image address — enter the address shown below:

```docker
xopero/gitprotect-agent:latest
```

<figure><img src="https://696332517-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtsE6XtJyUIEKVdSxPlS3%2Fuploads%2FPDVy8RQ5Zpa2PQZkrOQg%2Fimage.png?alt=media&#x26;token=3fde727a-01f4-4c36-a4c6-d029266a94bd" alt="" width="563"><figcaption></figcaption></figure>

5. Make sure you select the option **Try pulling the image from the registry before creating the container** (this ensures that the latest version of the image is used) and click **Next** to continue.
6. You can now edit the container settings as you would when creating a new container. Adjust them if needed, then click **Next** again to move to the summary page.

<figure><img src="https://696332517-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtsE6XtJyUIEKVdSxPlS3%2Fuploads%2Fh0fA09c17hxpqs2Q2zy9%2Fimage.png?alt=media&#x26;token=2e61e917-c090-4185-ac5e-47793d40d7b5" alt="" width="563"><figcaption></figcaption></figure>

7. Review the summary of the settings and changes. When everything looks correct, click **Finish**. **Container Station** will download the latest image and create a new container using the settings and data from the previous one. This updates the **worker** to the latest version while preserving all existing settings and data.

<figure><img src="https://696332517-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtsE6XtJyUIEKVdSxPlS3%2Fuploads%2F60R8RQvThoLMdhZCZUtM%2Fimage.png?alt=media&#x26;token=acc5a54c-280f-4bcd-ad3d-61b00b3b8935" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="QNAP NAS (CS < 3.0)" %}
{% hint style="danger" %}
The only way to update a **worker** installed in a container is to remove the existing version and install a new one. Creating a new container requires reactivating the device, so you will need to reassign it to all backup plans.
{% endhint %}

## Update process

1. Log in to **GitProtect Management Service**.
2. Find the **Docker worker**.
3. Click the **device details** ℹ️ button. Review the **Docker worker** plans and note them, as you will need to add them again. All plans can be viewed in the **Backup plans** section; expand the list by clicking **Load more**.
4. Remove the old **GitProtect worker** container — in **Container Station**, click the **Remove** icon in the **Actions** tab to delete the container.
5. Once the old container has been removed, install the **GitProtect agent Docker** image again. Then, add the **worker** to all the plans it was previously assigned to.
   {% endtab %}

{% tab title="Synology NAS (Container Manager)" %}

## Update process

1. When using the `:latest` tag, the **Container Manager** monitors the image for updates. When a new version is detected, the **Image** tab will show the status **Update available**. Click the status to start the update process.

{% hint style="warning" %}
If the **Update available** button does not appear even when the **worker** update is available for other devices, you may wait up to 12 hours before it becomes visible.
{% endhint %}

<figure><img src="https://696332517-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtsE6XtJyUIEKVdSxPlS3%2Fuploads%2FjWlxHODrvVXsDPpQ4LMI%2Fu1.png?alt=media&#x26;token=7063d08f-f57b-4f14-a8bb-764adf2561d7" alt="" width="563"><figcaption></figcaption></figure>

2. When activated, a system prompt will indicate that the services and container will be temporarily suspended during the update. Confirm by clicking the **Update** button.

<figure><img src="https://696332517-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtsE6XtJyUIEKVdSxPlS3%2Fuploads%2FuAGWkHLdIu8KmN5eostR%2Fu2.PNG?alt=media&#x26;token=1b1c3af8-5d68-4a89-a753-48363168df33" alt="" width="563"><figcaption></figcaption></figure>

3. You will be prompted to confirm the update again by clicking the **Update** button.

<figure><img src="https://696332517-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtsE6XtJyUIEKVdSxPlS3%2Fuploads%2FL2EXdlYHjPCvD9n9geGm%2Fu3.PNG?alt=media&#x26;token=66bcdb0f-d933-4c3b-a886-00df0e44f1b3" alt="" width="563"><figcaption></figcaption></figure>

4. The update progress will appear in the list of operations. Once the image is successfully downloaded, containers set to **auto-start** will restart automatically.

<figure><img src="https://696332517-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtsE6XtJyUIEKVdSxPlS3%2Fuploads%2Fhz9TUajsOwgAmcB5GooW%2Fu4.PNG?alt=media&#x26;token=d9855b24-6e68-4f22-b731-a52a81d5cc38" alt="" width="563"><figcaption></figcaption></figure>

5. To verify the update, go to the **Containers** tab to check that the container is functioning correctly. Also, check if the system shows the latest version in **GitProtect Management Service**.
   {% endtab %}
   {% endtabs %}
