Linux Applications NextCloud

How to Reset/Uninstall NextCloud AIO Completely

While installing NextCloud AIO on Docker, you might make mistakes and you might have difficulty fixing those and starting over. To start over a NextCloud AIO instance, you will have to properly reset/uninstall the NextCloud AIO instance completely.

In this article, I am going to show you how to properly reset/uninstall the NextCloud AIO instance so that you can start a fresh NextCloud AIO instance in case you’ve made a mistake installing NextCloud AIO.

 

Table of Contents

  1. Listing All the NextCloud AIO Docker Containers
  2. Removing All the NextCloud AIO Docker Containers
  3. Listing All the NextCloud AIO Docker Volumes
  4. Removing All the NextCloud AIO Docker Volumes
  5. Listing All the NextCloud AIO Docker Networks
  6. Removing All the NextCloud AIO Docker Networks
  7. Removing All the NextCloud AIO Docker Images
  8. Cleaning the NextCloud Data Directory
  9. Conclusion
  10. References

 

Listing All the NextCloud AIO Docker Containers

You can find a list of all the NextCloud AIO docker containers with the following command:

$ sudo docker container ls --all --filter "name=nextcloud-aio" --format "{{.ID}}\t\t\t{{.Names}}"

 

As you can see, the container ID and the name of all the NextCloud AIO docker containers are listed.

To properly reset/uninstall NextCloud AIO, you will need to remove them all.

 

Removing All the NextCloud AIO Docker Containers

To remove all the NextCloud AIO docker containers, run the following command:

$ for CID in `sudo docker container ls --all --filter "name=nextcloud-aio" --format "{{.ID}}"`; do sudo docker container rm --force $CID && echo "NextCloud AIO container $CID removed."; done

 

All the NextCloud AIO docker containers should be removed.

 

Listing All the NextCloud AIO Docker Volumes

You can find a list of all the NextCloud AIO docker volumes with the following command:

$ sudo docker volume ls --filter "name=nextcloud_aio"

 

As you can see, all the NextCloud AIO docker volumes are listed.

To properly reset/uninstall NextCloud AIO, you must remove all those docker volumes.

 

Removing All the NextCloud AIO Docker Volumes

To remove all the NextCloud AIO docker volumes, run the following command:

$ for VName in `sudo docker volume ls --filter "name=nextcloud_aio" --format "{{.Name}}" `; do sudo docker volume rm --force $VName && echo "NextCloud AIO Volume $VName removed."; done

 

All the NextCloud AIO docker volumes should be removed.

 

Listing All the NextCloud AIO Docker Networks

You can find a list of all the NextCloud AIO docker networks with the following command:

$ sudo docker network ls --filter "name=nextcloud-aio"

 

As you can see, all the NextCloud AIO docker networks are listed.

To properly reset/uninstall NextCloud AIO, you must remove all the NextCloud AIO docker networks.

 

Removing All the NextCloud AIO Docker Networks

To remove all the NextCloud AIO docker networks, run the following command:

$ for VNet in `sudo docker network ls --filter "name=nextcloud-aio" --format "{{.ID}}" `; do sudo docker network rm --force $VNet && echo "NextCloud AIO Network $VNet removed."; done

 

All the NextCloud AIO docker networks should be removed.

 

Removing All the NextCloud AIO Docker Images

You can find a list of all the cached NextCloud AIO docker images with the following command:

$ sudo docker image ls

 

All the cached NextCloud AIO docker images should be listed. You can remove all the cached NextCloud AIO Docker images if you want. This is optional.

 

To remove all the unused cached docker images including the NextCloud AIO docker images, run the following command:

$ sudo docker image prune --all

 

To confirm the operation, press Y and then press <Enter>.

 

All the cached Docker images including the NextCloud AIO images should be removed.

 

Cleaning the NextCloud Data Directory

If you have stored the NextCloud data in a directory instead of a Docker volume, you will need to clean that up as well.

I have stored the NextCloud data in the /mnt/nextcloud-data directory as you can see in the screenshot below.

$ grep DATADIR /opt/nextcloud-aio/compose.yaml

 

To remove all the contents of the NextCloud data directory /mnt/nextcloud-data (but not the NextCloud data directory itself), run the following command:

$ sudo rm -rfv $(sudo find /mnt/nextcloud-data -mindepth 1 -maxdepth 1)

 

All the contents of the NextCloud data directory /mnt/nextcloud-data should be removed.

 

As you can see, the NextCloud data directory /mnt/nextcloud-data is now empty.

$ sudo ls -lha /mnt/nextcloud-data

 

Conclusion

In this article, I have shown you how to reset/uninstall the NextCloud AIO docker instance completely so that you can start a new NextCloud AIO instance from scratch in case you’ve made a mistake installing NextCloud AIO.

 

References

  1. GitHub – nextcloud/all-in-one: The official Nextcloud installation method. Provides easy deployment and maintenance with most features included in this one Nextcloud instance.
  2. docker ps | Docker Docs
  3. docker container rm | Docker Docs
  4. docker volume ls | Docker Docs
  5. docker volume rm | Docker Docs
  6. docker network rm | Docker Docs
  7. docker network ls | Docker Docs
  8. docker image prune | Docker Docs

 

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.