# Perform a major upgrade of a Docker image

Supported in: This document explains how to perform a major upgrade for an existing Remote
Agent using its Docker image. This procedure covers pulling the latest image,
creating a backup of the existing container, preserving essential environment
variables, and restarting the newly upgraded agent.

## Before you begin

This procedure assumes you've already selected the Remote Agent upgrade option
and are viewing the **Major Upgrade** dialog. Confirm that your firewall
allows outbound HTTPS access on TCP port `443` to the container registries listed
in
[Network and firewall requirements](https://docs.cloud.google.com/chronicle/docs/soar/working-with-remote-agents/requirements-and-prerequisites#network-and-firewall-requirements).

In the **Major Upgrade** dialog, copy the Docker command and paste it
here. This command will be automatically populated in [Step 7](https://docs.cloud.google.com/chronicle/docs/soar/working-with-remote-agents/upgrade-agent-docker-image#step-7):

```bash
DOCKER_COMMAND
```

## Upgrade existing Remote Agent

To upgrade an existing Remote Agent using its Docker image, follow these steps:

1. Run the following command to list the current running Docker containers to identify your agent's container ID and name:

   ```bash
   docker ps
   ```
2. Enter your agent's container ID and name:

   ```bash
   CONTAINER_ID
   ```

   ```bash
   AGENT_NAME
   ```
3. Run the following command to pull the latest Docker image to your machine: You can change the `latest` tag to a specific version, such as `1.4.8.3`.

   ```bash
   docker pull us-docker.pkg.dev/siem-ar-public/images/agent:latest
   ```
4. Run the following command to copy the modified environment variables to a local temporary file:

   ```bash
   docker exec CONTAINER_ID cat /home/siemplify_agent/.bash_profile > temp_bash_profile.txt
   ```
5. Run the following command to stop the agent's Docker container:

   ```bash
   docker stop CONTAINER_ID
   ```
6. Run the following command to rename the container to create a backup:

   ```bash
   docker rename AGENT_NAME AGENT_NAME_backup
   ```
7. Run the new agent image. If you used a specific version for the `latest` tag in [Step 3](https://docs.cloud.google.com/chronicle/docs/soar/working-with-remote-agents/upgrade-agent-docker-image#step-3), use the same tag here:

   *Note: This command is populated from the [Before you begin](https://docs.cloud.google.com/chronicle/docs/soar/working-with-remote-agents/upgrade-agent-docker-image#before-you-begin) section.*

   ```bash
   DOCKER_COMMAND
   ```
8. Run the following command to list the running Docker containers to find the new container ID:

   ```bash
   docker ps
   ```
9. Enter your agent's new container ID:

   ```bash
   NEW_CONTAINER_ID
   ```
10. Run the following command to copy the original contents of `.bash_profile` to the new container:

    ```bash
    cat temp_bash_profile.txt | docker exec -i
        NEW_CONTAINER_ID sh -c 'cat > /home/siemplify_agent/.bash_profile'
    ```
11. Run the following command to restart the agent service to apply the modified environment variables:

    ```bash
    docker exec NEW_CONTAINER_ID supervisorctl restart all
    ```

**Need more help?** [Get answers from Community members and Google SecOps professionals.](https://security.googlecloudcommunity.com/)