# Safely Recreating Nextcloud AIO Docker Containers with NFS Storage

## 🎯 Purpose

To safely re-create all Docker containers in your Nextcloud AIO deployment while preserving data and configuration stored in persistent volumes.

## 📍 Requirements

- NFS share must be online and mounted correctly.
- Docker and Docker Compose installed.
- Working directory is `~/nextcloud-aio` where `docker-compose.yml` resides.

## 📦 Why This Works

Nextcloud AIO separates runtime containers from data using persistent volumes:

- `nextcloud_aio_mastercontainer`: Local volume storing AIO configuration.
- `nextcloud_ncdata`: Remote volume (via NFS) storing all Nextcloud data.

As long as these volumes remain untouched, you can destroy and recreate containers safely.

## 🛠 Step-by-Step Procedure

### Step 1: Shut Down Containers

```
cd ~/nextcloud-aio
docker compose down

```

### Step 2: Update Images (Optional)

```
docker compose pull

```

### Step 3: Recreate Containers

```
docker compose up -d

```

Your containers will be rebuilt and relaunched using existing configurations and data.

## 🧪 Verify Volume Health

```
docker volume ls
docker volume inspect nextcloud_ncdata

```

You should see the correct mount info like:

```
"device": ":/mnt/hdd-storage/nfs-nextcloud",
"o": "addr=192.168.100.11,nfsvers=4,soft,timeo=900,retrans=5,rw,noatime,nolock"

```

## 🔥 Optional: Clean Up Old Images

```
docker image prune -a
docker container prune

```

## 🔐 UFW Rules (if using UFW)

```
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 8080/tcp
sudo ufw allow 3478/tcp
sudo ufw allow 3478/udp

```

This ensures access to HTTP/HTTPS and TURN services.

## ✅ Summary

You can safely re-create all containers in your Nextcloud AIO environment without data loss by:

- Preserving your Docker volumes
- Validating NFS mount and permissions
- Using Docker Compose to rebuild with `up -d`

This helps keep your Nextcloud instance stable, secure, and up to date.

*Maintained by MSLS Partners LLC — Internal Infrastructure Guide*