# Docker Container keeps restarting - Troubleshooting Nextcloud

This case, it was already working. Ended up pulling a new image but didnt know it.

First, check docker logs. Run the container and let it keep restarting so that it will give you an error log.

```bash
docker logs <nextcloud_container_name>
```

Error said:  
Initializing nextcloud 31.0.1.2 ...  
Can't start Nextcloud because upgrading from 29.0.0.19 to 31.0.1.2 is not supported.  
It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16.

That means files/data is for version 29 and i need to incrementally go up to V31.

Lets get the versions in between to install it correctly.

If the containers are running. stock them.

```bash
docker-compose down
```

#### Check Your Current Data

Your Nextcloud data (files and database) is tied to version 29.0.0.19. Ensure your volumes (<span class="text-sm px-1 rounded-sm !font-mono bg-sunset/10 text-rust dark:bg-dawn/10 dark:text-dawn">./nextcloud</span> and <span class="text-sm px-1 rounded-sm !font-mono bg-sunset/10 text-rust dark:bg-dawn/10 dark:text-dawn">./mariadb</span>) are intact, as they contain your files and database. If you have backups, now’s a good time to confirm they’re ready—just in case.

#### Upgrade Step-by-Step

You’ll need to run intermediate versions of Nextcloud to perform the upgrades. Modify your <span class="text-sm px-1 rounded-sm !font-mono bg-sunset/10 text-rust dark:bg-dawn/10 dark:text-dawn">docker-compose.yml</span> to pull specific versions, starting with the next major version after 29.

#### Upgrade Step-by-Step

- You’ll need to run intermediate versions of Nextcloud to perform the upgrades. Modify your <span class="text-sm px-1 rounded-sm !font-mono bg-sunset/10 text-rust dark:bg-dawn/10 dark:text-dawn">docker-compose.yml</span> to pull specific versions, starting with the next major version after 29.

```yaml
services:
  nextcloud:
    image: nextcloud:30
    # ... rest of your config ...
  mariadb:
    # ... no change needed here ...
```

- Start the containers:

```bash
docker-compose up -d
```

- Check the logs to confirm it’s running:

```bash
docker-compose logs -f
```

- Nextcloud should automatically run the upgrade process for version 30. Wait until it stabilizes (logs should stop showing errors and indicate a successful start).

#### Upgrade to 31.0.x

- Once version 30 is running fine, stop the containers:

```bash
docker-compose down
```

<div id="bkmrk-update-docker-compos">- Update <span class="text-sm px-1 rounded-sm !font-mono bg-sunset/10 text-rust dark:bg-dawn/10 dark:text-dawn">docker-compose.yml</span> to the desired version (31.0.1.2 or latest 31):

</div>```yaml
services:
  nextcloud:
    image: nextcloud:31
    # ... rest of your config ...
```

<div id="bkmrk-restart%3A">- Restart:

</div>```
docker-compose up -d
```

- Check logs again:

```
docker-compose logs -f
```

 The upgrade from 30 to 31 should proceed. Once complete, your Nextcloud should be fully operational on 31.0.1.2.

<div id="bkmrk-"></div>