Docker

Useful staff for Docker and not only.

Free Space from Docker container.

The below commands are useful to free up space from containers leave unused images, volumes, networks, logs.
From the cli where there is Docker installed run the below commands.

Commands
docker image prune -f -a
docker system prune --volumes -f -a
find /var/lib/docker/containers/ -type f -name "*.log" -delete
Download script

Or you can download the below shell script and add a Cron Job to run every 1 hour.

Download : docker-freeup-space.sh

Cron Job

Run crontab to add the job.

crontab -e

Then go to the end of the lines and add the below.

0 * * * * /path-of-the-script/docker-freeup-space.sh

Save and Exit

Done.

Ins0mniA

Useful Docker commands

Stop all Docker containers

To stop all Docker containers from the command line, you can use the following command:

docker stop $(docker ps -q)

Explanation:

So, $(docker ps -q) will pass all running container IDs to docker stop, effectively stopping all of them.

Remove ALL Docker containers Networks

WARNING (USED / UNUSED Networks) This will remove all Networks from ALL container even the one you use.

docker network rm $(docker network ls -q)

Explanation:

This will attempt to remove all networks, including the default ones if they are not in use by containers. However, if a network is in use by a container, Docker won't allow you to remove it without first disconnecting the containers.

If you really want to remove all networks including the ones in use, you'd have to stop and remove the containers using those networks first.

Remove all Docker volumes (including unused ones)

To remove all Docker volumes (including unused ones), you can use the following command:

docker volume prune -f -a

Explanation:

If you want to remove all volumes — even the ones in use by containers (which is dangerous and typically not recommended) — you'd need to remove the containers and then delete the volumes.
Here's how you can do it:

1. Stop and remove all containers:

docker stop $(docker ps -q)
docker rm $(docker ps -aq)

2. Remove all volumes:

docker volume rm $(docker volume ls -q)

Caution:

Remove all Docker images (including images that are not being used by any containers)

To remove all unused images (not in use by any container), including dangling images, you can run:

docker image prune -f -a

Explanation:

To remove all Docker images (including images that are not being used by any containers), you can use the following command:

docker rmi $(docker images -q)

Explanation:

If you have containers using some of these images:
If there are containers still using these images, Docker will not let you remove them. To force removal, you'd need to stop and remove the containers first.
Here's how to do it:

1. Stop all running containers:

docker stop $(docker ps -q)

2. Remove all containers:

docker rm $(docker ps -aq)

3. Remove all images:

docker rmi $(docker images -q)

Caution:

Remove all stacks of containers in Docker

To remove all stacks of containers in Docker, you'll typically be dealing with Docker Swarm. A stack in Docker refers to a collection of services deployed in a Docker Swarm, often using docker stack deploy.

If you want to remove all stacks (and the services, networks, and containers associated with them), you can do so with the following command:

docker stack rm $(docker stack ls -q)

Explanation:

This will remove all stacks deployed in your Docker Swarm environment.

Important Notes:

Ins0mniA

Install Docker on Debian

🚀 One-Line Download & Execute

apt install -y curl && curl -sSL https://docs.greenhome.stream/attachments/37 -o install_docker_portainer.sh && chmod +x install_docker_portainer.sh && ./install_docker_portainer.sh

Method A :

1. Install Docker on Debian 12

Before you install Docker Compose and Portainer, ensure that Docker is installed on your Debian 12 system.

Step 1: Update and Install Dependencies
apt update
apt install -y apt-transport-https ca-certificates curl
Step 2: Add Docker’s Official GPG Key
curl -fsSL https://download.docker.com/linux/debian/gpg | tee /etc/apt/trusted.gpg.d/docker.asc
Step 3: Add Docker's Official Repository
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list
Step 4: Install Docker
apt update
apt install -y docker-ce docker-ce-cli containerd.io
Step 5: Verify Docker Installation
docker --version

Method B :

2. Install Docker Compose and Enable APT Updates

Step 1: Add Docker Compose APT Repository

Docker Compose is not included in the default Debian repositories, but you can use Docker’s official repository for Compose.

Create a Docker Compose APT repository source:

echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list
Step 2: Install Docker Compose

Now, install Docker Compose from Docker's APT repository:

apt update
apt install -y docker-compose-plugin

This version of Docker Compose (the plugin version) integrates directly into the Docker CLI and will update with apt update and apt upgrade.

Step 3: Verify Docker Compose Installation
docker compose version

Method C :

3. Install Portainer Using Docker Compose (Optional)

Portainer is a popular web UI to manage Docker environments. You can easily deploy it using Docker Compose.

Step 1: Create the docker-compose.yml File

Create a docker-compose.yml file in a directory where you want to manage Portainer. You can place it anywhere you like, but let’s say you create a directory called portainer :

mkdir -p ~/portainer
cd ~/portainer

Now create the docker-compose.yml file using your favorite editor:

nano docker-compose.yml

Paste the following content for the Portainer setup:

version: "3.9"
services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: always
    networks:
      - portainer_network
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    ports:
      - 9000:9000
    environment:
      - TZ=Europe/Athens  # Set your timezone

networks:
  portainer_network:
    driver: bridge

volumes:
  portainer_data:
    driver: local
Step 2: Start Portainer

Once the docker-compose.yml file is ready, run the following command to start Portainer :

docker compose up -d

This will pull the Portainer image, create the necessary containers, and start the Portainer web UI. You can now access it by going to http://<your-server-ip>:9000 in your web browser.

Step 3: Access Portainer

When you visit Portainer for the first time, you'll be prompted to set up an admin account. After that, you can start managing your Docker environment through the web interface.


Method D :

1. Install Docker

Step 1:

Install docker using the official script, by executing the below command.

curl -fsSL https://get.docker.com | sh

Check Update :

4. Ensure Automatic Updates for Docker and Docker Compose

Since you added Docker’s official repositories, Docker Compose will be updated via the same process as Docker itself when you run :

apt update && apt upgrade -y

Summary

  1. Docker : Installed and running using the official Docker repositories.
  2. Docker Compose : Installed via Docker's APT repository and integrated with Docker.
  3. Portainer : Deployed using Docker Compose, with an example docker-compose.yml file to start the Portainer service.

You should now have Docker, Docker Compose, and Portainer running on Debian 12, with updates managed through apt .

Download the files

Script universal-health-monitor.sh

Ins0mniA

Install Docker ANY Linux Distro

Docker Installer & Verifier

A production-ready bash script that detects whether Docker is already installed and, if not, installs Docker CE + the Docker Compose plugin using the official repository for your Linux distribution.

🚀 One-Line Download & Execute :
apt update && apt install -y curl && clear && curl -s https://docs.greenhome.stream/attachments/69 | bash

🇬🇧 English

Features

Requirements

Usage

Download and run:

curl -fsSL -o install-docker.sh https://example.com/install-docker.sh
chmod +x install-docker.sh
./install-docker.sh

Or if you already have it locally:

chmod +x install-docker.sh
./install-docker.sh

What it does, step by step

  1. Clears the screen and shows a banner.
  2. Sets up sudo — uses root if already root, otherwise requires sudo.
  3. Detects OS family via /etc/os-release and picks the right package manager.
  4. Checks if Docker is installed — verifies the binary, the daemon, and the Compose plugin.
  5. If everything is OK → exits with a green success message. Nothing is installed.
  6. If only Compose is missing → installs only the Compose plugin.
  7. If Docker is missing → adds the official Docker repository for your distro, installs docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin, docker-compose-plugin, enables and starts the service, runs hello-world as a final sanity check, and adds your user to the docker group.

Exit codes

Troubleshooting


🇬🇷 Ελληνικά

Χαρακτηριστικά

Προϋποθέσεις

Χρήση

Κατεβάστε και τρέξτε:

curl -fsSL -o install-docker.sh https://example.com/install-docker.sh
chmod +x install-docker.sh
./install-docker.sh

Ή, αν το έχετε ήδη τοπικά:

chmod +x install-docker.sh
./install-docker.sh

Τι κάνει, βήμα προς βήμα

  1. Καθαρίζει την οθόνη και εμφανίζει banner.
  2. Ρυθμίζει sudo — χρησιμοποιεί root αν είστε ήδη root, διαφορετικά απαιτεί sudo.
  3. Εντοπίζει την οικογένεια OS μέσω του /etc/os-release και επιλέγει τον κατάλληλο package manager.
  4. Ελέγχει αν είναι εγκατεστημένο το Docker — επαληθεύει binary, daemon, και το Compose plugin.
  5. Αν όλα είναι εντάξει → τερματίζει με πράσινο μήνυμα επιτυχίας. Δεν εγκαθιστά τίποτα.
  6. Αν λείπει μόνο το Compose → εγκαθιστά μόνο το Compose plugin.
  7. Αν λείπει το Docker → προσθέτει το επίσημο αποθετήριο Docker για τη διανομή σας, εγκαθιστά docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin, docker-compose-plugin, ενεργοποιεί και ξεκινά την υπηρεσία, τρέχει το hello-world ως τελικό έλεγχο, και προσθέτει τον χρήστη στην ομάδα docker.

Κωδικοί εξόδου

Αντιμετώπιση προβλημάτων


License

MIT — use, modify, and redistribute freely.