# Upgrading a docker container from before 2025

Before 2025, upgrading the Tillit Edge Docker required destroying the existing container, which led to missing files necessary for the new version. Starting in 2025, this issue has been resolved, and upgrades can now be performed without losing critical files.

If your `docker-compose.yml` file resembles the example below and is missing the lines added in "Since 2025," you will need to complete pre-upgrade steps before proceeding with the upgrade. If not, then you can easily use `docker compose pull` and `docker compose up -d --force-recreate` to upgrade to latest version of the image

### Example docker-compose File Before 2025

```
version: '3.7'
services:
  TillitEdge:
    image: gotillit/edge:latest
    environment:
      - INIT_CONFIG=/greengrass/v2/config.yaml
      - AWS_REGION=ap-southeast-2
    volumes:
      - ./tillitEdgeConfig:/tillit/
      - ./SystemsManagerConfig:/var/lib/amazon/ssm
    privileged: true #Allows device defender to read from tmpfs
    restart: always
```

### Example docker-compose File Since 2025

```
services:
  TillitEdge:
    image: gotillit/edge:latest
    environment:
      - INIT_CONFIG=/greengrass/v2/config.yaml
      - AWS_REGION=ap-southeast-2
    volumes:
      - ./tillitEdgeConfig:/tillit/
      - ./greengrass/packages:/greengrass/v2/packages
      - ./greengrass/deployment:/greengrass/v2/deployments
      - ./greengrass/config:/greengrass/v2/config
      - ./greengrass/logs:/greengrass/v2/logs
    restart: always
```

## Pre-Upgrading Before 2025

If you are upgrading from a version prior to 2025, you will need to copy required files from the running container to the host system in the same directory as your `docker-compose.yml` file. Below are the steps to accomplish this:

**Using Command Line (Recommended)**

1. **Open a Terminal:** Open a terminal window and list the running containers:

   ```
   docker container list
   ```
2. **Copy the Container ID:** Locate and copy the Container ID of the TilliT Edge container you wish to update.
3. **Prepare the Host Directory:** Navigate to the directory containing the `docker-compose.yml` file and create a `greengrass` directory:

   ```
   mkdir greengrass
   ```
4. **Copy Files from the Container:** Use the following commands to copy the necessary files from the container to your local directory. Replace `<container_id>` with the Container ID from Step 2:

   ```
   docker cp <container_id>:/greengrass/v2/packages ./greengrass/packages
   docker cp <container_id>:/greengrass/v2/deployments ./greengrass/deployments
   docker cp <container_id>:/greengrass/v2/config ./greengrass/config
   docker cp <container_id>:/greengrass/v2/logs ./greengrass/logs
   ```
5. **Update the `docker-compose.yml`:** Modify the `docker-compose.yml` file to include the updates listed in "Since 2025."
6. **Pull the Latest Image:** Run the following command to pull the latest version of the TilliT Edge image:

   ```
   docker-compose pull
   ```
7. **Recreate the Container:** Restart the container with the latest version of the image:

   ```
   docker-compose up -d --force-recreate
   ```
8. **Verify the Upgrade:** Check in TilliT to ensure the Edge is functioning as expected.

### Using Docker Desktop (Not Recommended)

1. **Prepare the Host Directory:** Open the folder location containing the `docker-compose.yml` file and create a `greengrass` directory.
2. **Access the Container Files:** Open Docker Desktop and locate the TilliT Edge container. Navigate to the **Files** tab, then open the `greengrass/v2` directory within the container.
3. **Copy Required Folders:** Save the following folders by right clicking them from the container to the `greengrass` directory on your host system:
   * `packages`
   * `deployments`
   * `config`
   * `logs`
4. **Update the Image:** In Docker Desktop, go to the **Images** panel and select **Pull** from the context menu to update the image.
5. **Recreate the Container:** Open a terminal, navigate to the directory containing the `docker-compose.yml` file, and run the following commands:

   ```
   docker-compose pull
   docker-compose up -d --force-recreate
   ```
6. **Verify the Upgrade:** Check in TilliT to ensure the Edge is functioning as expected.
