Skip to content

Uninstall

BenM edited this page Jul 25, 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 customize 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 bash uninstaller.sh
  3. Done

Script Uninstall

#!/usr/bin/env bash

CONTAINER_NAME="hashtopolis"
DB_NAME="db"
IMAGE_BACKEND_NAME="hashtopolis/backend"
IMAGE_FRONTEND_NAME="hashtopolis/frontend"
VOLUME_NAME="server_hashtopolis"
VOLUME_DB_NAME="server_db"
NETWORK_NAME="server_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_BACKEND_NAME"
docker image rmi "$IMAGE_FRONTEND_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