Docker
docker compose
Add your user to the docker group
Step 1: Run command > sudo usermod -aG docker $USER
Step 2: Logout from the machine
Step 3: Relogin and Run docker command without sudo
Working with docker running in remote machine
Pre-Condition: User should be added to docker group
Step 1: Add host in ~/.ssh/config
Host <SSH_HOST_ALIAS>
HostName <HOST_IP_OR_HOSTNAME>
User <LOGIN_USERNAME>
IdentityFile <PATH_TO_PRIVATE_KEY>
# Restrict authentication to the specified private key
IdentitiesOnly yes
Step 2: Create Docker contexts using those host aliases.
Step 3: Test the connection
Step 4: Switch to the context
Step 5: To show current active context
Clean up
| Target Resource | Safe / Default Prune | Aggressive / Complete Prune | What it Removes |
|---|---|---|---|
| Global System | docker system prune |
docker system prune -a --volumes |
Stopped containers, unused networks, build caches, and images. |
| Images | docker image prune |
docker image prune -a |
Default removes "dangling" (untagged) images; -a removes all unused images. |
| Containers | docker container prune |
N/A (Default removes all) | Removes all stopped containers. |
| Volumes | docker volume prune |
docker volume prune --filter all=1 |
Removes local volumes not used by any remaining containers. |
| Networks | docker network prune |
N/A (Default removes all) | Removes all networks not used by at least one container. |
| Build Cache | docker builder prune |
docker builder prune -a |
Frees up cache space generated during image building stages. |