Skip to content

Uninstall

BenDM edited this page Jul 19, 2023 · 9 revisions

Overview

This guide explains how to completely remove a Hashtolopis system which had been installed using Docker, including removing files, database and network.

Before you start

If you simply want to update version and wish to keep Database, Files and Network, just delete the respective lines on the script below.

Steps

  1. Go to your project or preferred location and create a file touch uninstaller.sh, then nano uninstaller.sh and paste the script below
  2. Run the script sh uninstaller.sh
  3. Done

Script Uninstall

#!/usr/bin/env bash
#
CONTAINER_NAME="hashtopolis-backend"
DB_NAME="db"
IMAGE_NAME="dev_hashtopolis-backend"
VOLUME_NAME="dev_db"
VOLUME_DB_NAME="dev_hashtopolis"
NETWORK_NAME="dev_default"

# 1 - Stop and remove running app container(s)
docker ps -q --no-trunc --filter "name=$CONTAINER_NAME" | xargs -r docker stop
docker ps -a -q --filter "name=$CONTAINER_NAME" | xargs -r docker rm
# 2 - Stop and remove running app container(s)
docker ps -q --no-trunc  --filter "name=$DB_NAME" | xargs -r docker stop
docker ps -a -q --filter "name=$DB_NAME" | xargs -r docker rm
# 3 - Remove Volume, comment this line if you don't want to the volume
docker volume ls --filter "name=$VOLUME_NAME" | xargs -r docker volume rm --force
docker volume ls --filter "name=$VOLUME_DB_NAME" | xargs -r docker volume rm --force
# 4 - Remove image
docker image rmi "$IMAGE_NAME"
# 5 - Remove Network
docker network ls -q --no-trunc --filter "name=$NETWORK_NAME" | xargs -r docker network rm --force
# 6 - Prune container and volume
docker container prune -f && docker volume prune -f