howto:docker
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| howto:docker [2026/01/24 11:53] – created nathna | howto:docker [2026/01/25 11:00] (current) – nathna | ||
|---|---|---|---|
| Line 20: | Line 20: | ||
| <code bash> | <code bash> | ||
| # Remove old versions (optional) | # Remove old versions (optional) | ||
| - | sudo apt remove docker docker-engine docker.io containerd runc | + | sudo apt remove |
| # Install dependencies | # Install dependencies | ||
| - | |||
| sudo apt update | sudo apt update | ||
| sudo apt install -y ca-certificates curl gnupg lsb-release | sudo apt install -y ca-certificates curl gnupg lsb-release | ||
| # Add Docker’s official GPG key | # Add Docker’s official GPG key | ||
| - | |||
| sudo install -m 0755 -d / | sudo install -m 0755 -d / | ||
| - | curl -fsSL [https:// | + | curl -fsSL https:// |
| sudo chmod a+r / | sudo chmod a+r / | ||
| # Add Docker repository | # Add Docker repository | ||
| - | + | echo "deb [arch=$(dpkg --print-architecture) signed-by=/ | |
| - | echo "deb [arch=$(dpkg --print-architecture) signed-by=/ | + | |
| # Install Docker Engine | # Install Docker Engine | ||
| - | |||
| sudo apt update | sudo apt update | ||
| - | sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin </ | + | sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin |
| + | </ | ||
| - | ==== Enable & Start Docker ==== <code bash> | + | ==== Enable & Start Docker ==== |
| + | <code bash> | ||
| sudo systemctl enable docker | sudo systemctl enable docker | ||
| - | sudo systemctl start docker </ | + | sudo systemctl start docker |
| + | </ | ||
| --- | --- | ||
| ===== 👤 3. Add Your User to the docker Group ===== | ===== 👤 3. Add Your User to the docker Group ===== | ||
| - | This lets you run Docker without sudo. <code bash> | + | This lets you run Docker without sudo. |
| + | |||
| + | <code bash> | ||
| sudo usermod -aG docker $USER | sudo usermod -aG docker $USER | ||
| - | newgrp docker </ | + | newgrp docker |
| + | </ | ||
| --- | --- | ||
| Line 63: | Line 65: | ||
| </ | </ | ||
| - | Verify: <code bash> | + | Verify: |
| - | docker-compose --version </ | + | <code bash> |
| + | docker-compose --version | ||
| + | </ | ||
| --- | --- | ||
| Line 101: | Line 105: | ||
| ===== ▶️ 7. Start Containers ===== | ===== ▶️ 7. Start Containers ===== | ||
| - | Using Docker Compose v2: <code bash> | + | Using Docker Compose v2: |
| - | docker compose up -d </ | + | |
| - | + | ||
| - | Using docker-compose v1: <code bash> | + | |
| - | docker-compose up -d </ | + | |
| - | + | ||
| - | --- | + | |
| - | + | ||
| - | ===== 📌 8. Useful Docker Commands ===== | + | |
| - | **View running containers: | + | |
| - | docker ps </ | + | |
| - | + | ||
| - | **View logs:** <code bash> | + | |
| - | docker logs -f < | + | |
| - | + | ||
| - | **Restart container: | + | |
| - | docker restart < | + | |
| - | + | ||
| - | **Stop all containers: | + | |
| - | docker stop $(docker ps -q) </ | + | |
| - | + | ||
| - | **Remove all stopped containers: | + | |
| - | docker container prune </ | + | |
| - | + | ||
| - | --- | + | |
| - | + | ||
| - | ===== 🛠️ 9. Useful Docker Compose Commands ===== | + | |
| - | **Recreate after editing docker-compose.yml: | + | |
| - | docker compose down && docker compose up -d </ | + | |
| - | + | ||
| - | **Validate syntax:** <code bash> | + | |
| - | docker compose config </ | + | |
| - | + | ||
| - | --- | + | |
| - | + | ||
| - | ===== 🔄 10. Full Quick Setup (Copy/ | + | |
| - | Use this block for rapid setup on every new VM. | + | |
| <code bash> | <code bash> | ||
| - | sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y | ||
| - | |||
| - | sudo apt install -y ca-certificates curl gnupg lsb-release | ||
| - | sudo install -m 0755 -d / | ||
| - | curl -fsSL [https:// | ||
| - | sudo chmod a+r / | ||
| - | |||
| - | echo "deb [arch=$(dpkg --print-architecture) signed-by=/ | ||
| - | |||
| - | sudo apt update | ||
| - | sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
| - | |||
| - | sudo systemctl enable docker | ||
| - | sudo systemctl start docker | ||
| - | |||
| - | sudo usermod -aG docker $USER | ||
| - | newgrp docker </ | ||
| - | |||
| - | --- | ||
| - | |||
| - | If you’d like, I can also create a Portainer guide, Kubernetes migration steps, or a TorresVault VM baseline page. & Docker Compose Setup Guide for a Fresh Ubuntu VM | ||
| - | This page is designed for your TorresVault wiki. It provides a clean, repeatable checklist and command reference for preparing any new Ubuntu Server VM before deploying an app. This is the **standard baseline** you use across all your VMs. | ||
| - | |||
| - | --- | ||
| - | |||
| - | ## ✅ 1. Update & Upgrade the System | ||
| - | |||
| - | These commands ensure the VM is fully patched before installing anything. | ||
| - | |||
| - | ```bash | ||
| - | sudo apt update && sudo apt upgrade -y | ||
| - | sudo apt autoremove -y | ||
| - | sudo reboot | ||
| - | ``` | ||
| - | |||
| - | --- | ||
| - | |||
| - | ## 🐋 2. Install Docker | ||
| - | |||
| - | The recommended officially supported installation method. | ||
| - | |||
| - | ```bash | ||
| - | # Remove old versions (optional) | ||
| - | sudo apt remove docker docker-engine docker.io containerd runc | ||
| - | |||
| - | # Install dependencies | ||
| - | sudo apt update | ||
| - | sudo apt install -y ca-certificates curl gnupg lsb-release | ||
| - | |||
| - | # Add Docker’s official GPG key | ||
| - | sudo install -m 0755 -d / | ||
| - | curl -fsSL https:// | ||
| - | sudo chmod a+r / | ||
| - | |||
| - | # Add Docker repository | ||
| - | echo \ | ||
| - | "deb [arch=$(dpkg --print-architecture) signed-by=/ | ||
| - | $(lsb_release -cs) stable" | ||
| - | sudo tee / | ||
| - | |||
| - | # Install Docker Engine | ||
| - | sudo apt update | ||
| - | sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
| - | ``` | ||
| - | |||
| - | ### Enable & Start Docker | ||
| - | |||
| - | ```bash | ||
| - | sudo systemctl enable docker | ||
| - | sudo systemctl start docker | ||
| - | ``` | ||
| - | |||
| - | --- | ||
| - | |||
| - | ## 👤 3. Add Your User to the `docker` Group | ||
| - | |||
| - | This lets you run Docker without `sudo`. | ||
| - | |||
| - | ```bash | ||
| - | sudo usermod -aG docker $USER | ||
| - | newgrp docker | ||
| - | ``` | ||
| - | |||
| - | --- | ||
| - | |||
| - | ## 📦 4. Install Standalone Docker Compose (Optional) | ||
| - | |||
| - | Ubuntu now includes **Docker Compose v2**, but for apps needing older v1 (`docker-compose`) you can install manually. | ||
| - | |||
| - | ```bash | ||
| - | sudo curl -L " | ||
| - | sudo chmod +x / | ||
| - | ``` | ||
| - | |||
| - | Verify: | ||
| - | |||
| - | ```bash | ||
| - | docker-compose --version | ||
| - | ``` | ||
| - | |||
| - | --- | ||
| - | |||
| - | ## 📁 5. Create App Directory Structure | ||
| - | |||
| - | Standard layout for TorresVault app VMs. | ||
| - | |||
| - | ```bash | ||
| - | mkdir -p ~/ | ||
| - | mkdir -p ~/ | ||
| - | cd ~/ | ||
| - | ``` | ||
| - | |||
| - | --- | ||
| - | |||
| - | ## 🧱 6. Create a Standard `docker-compose.yml` | ||
| - | |||
| - | Template to reuse for each app. | ||
| - | |||
| - | ```yaml | ||
| - | version: " | ||
| - | services: | ||
| - | app: | ||
| - | image: < | ||
| - | container_name: | ||
| - | restart: unless-stopped | ||
| - | ports: | ||
| - | - " | ||
| - | volumes: | ||
| - | - ./ | ||
| - | - ./ | ||
| - | environment: | ||
| - | - TZ=America/ | ||
| - | ``` | ||
| - | |||
| - | --- | ||
| - | |||
| - | ## ▶️ 7. Start Containers | ||
| - | |||
| - | Using Docker Compose v2: | ||
| - | |||
| - | ```bash | ||
| docker compose up -d | docker compose up -d | ||
| - | ``` | + | </ |
| - | Using standalone | + | Using docker-compose |
| - | + | < | |
| - | ```bash | + | |
| docker-compose up -d | docker-compose up -d | ||
| - | ``` | + | </ |
| --- | --- | ||
| - | ## 📌 8. Useful Docker Commands | + | ===== 📌 8. Useful Docker Commands |
| - | + | **View running containers:** | |
| - | ### View running containers: | + | < |
| - | + | ||
| - | ```bash | + | |
| docker ps | docker ps | ||
| - | ``` | + | </ |
| - | ### View logs: | + | **View logs:** |
| - | + | < | |
| - | ```bash | + | |
| docker logs -f < | docker logs -f < | ||
| - | ``` | + | </ |
| - | ### Restart container: | + | **Restart container:** |
| - | + | < | |
| - | ```bash | + | |
| docker restart < | docker restart < | ||
| - | ``` | + | </ |
| - | + | ||
| - | ### Stop all containers: | + | |
| - | ```bash | + | **Stop all containers: |
| + | < | ||
| docker stop $(docker ps -q) | docker stop $(docker ps -q) | ||
| - | ``` | + | </ |
| - | ### Remove all stopped containers: | + | **Remove all stopped containers:** |
| - | + | < | |
| - | ```bash | + | |
| docker container prune | docker container prune | ||
| - | ``` | + | </ |
| --- | --- | ||
| - | ## 🛠️ 9. Useful Docker Compose Commands | + | ===== 🛠️ 9. Useful Docker Compose Commands |
| - | + | **Recreate after editing docker-compose.yml: | |
| - | ### Recreate | + | < |
| - | + | ||
| - | ```bash | + | |
| docker compose down && docker compose up -d | docker compose down && docker compose up -d | ||
| - | ``` | + | </ |
| - | ### Validate syntax: | + | **Validate syntax:** |
| - | + | < | |
| - | ```bash | + | |
| docker compose config | docker compose config | ||
| - | ``` | + | </ |
| --- | --- | ||
| - | ## 🔄 10. Full Quick Setup (Copy/ | + | ===== 🔄 10. Full Quick Setup (Copy/ |
| Use this block for rapid setup on every new VM. | Use this block for rapid setup on every new VM. | ||
| - | ```bash | + | < |
| sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y | sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y | ||
| Line 354: | Line 169: | ||
| sudo chmod a+r / | sudo chmod a+r / | ||
| - | echo \ | + | echo "deb [arch=$(dpkg --print-architecture) signed-by=/ |
| - | | + | |
| - | | + | |
| - | | + | |
| sudo apt update | sudo apt update | ||
| Line 367: | Line 179: | ||
| sudo usermod -aG docker $USER | sudo usermod -aG docker $USER | ||
| newgrp docker | newgrp docker | ||
| - | ``` | + | </ |
| - | + | ||
| - | --- | + | |
| - | + | ||
| - | If you'd like, I can also create: | + | |
| - | + | ||
| - | * A printable PDF version | + | |
| - | * A second page for **Portainer setup** | + | |
| - | * A TorresVault “standard VM template” page | + | |
howto/docker.1769273605.txt.gz · Last modified: by nathna
