Docker Cheatsheet for the Mindless

Docker Cheatsheet for the mindless chore

Here’s a tight, practical Docker cheat sheet for reloading your app depending on what you need 👇

🔄 1. Restart a running container

If your app is already built and you just want to restart it:

docker restart <container_name>

🔁 2. Rebuild + restart (most common)

When you changed code or dependencies:

    docker-compose down
    docker-compose up --build -d

Or with newer syntax:

    docker compose down
    docker compose up --build -d

⚡ 3. Fast reload (no rebuild)

If you’re using volumes (live code sync):

    docker compose restart

🧹 4. Clean rebuild (fix weird issues)

When things are broken/cached badly:

    docker compose down -v
    docker compose build --no-cache
    docker compose up -d

🛑 5. Stop everything

    docker compose down

🔍 6. Check what’s running

    docker ps

📜 7. View logs (super useful)

    docker compose logs -f

🎯 8. Restart ONE service only

    docker compose restart <service_name>

💡 Pro tips (this is usually what you want)

  • If code changes not showing → use –build

  • If permissions errors (“operation not permitted”) → try:

    docker compose down -v

If using Node/PHP dev → make sure volumes are mounted so you don’t rebuild every time

🐳 Docker Dev Cheat Sheet (Java + Python Hugging Face)

🧠 Goal

  • Avoid re-downloading Hugging Face models
  • Work independently on:

    • Python (AI service)
    • Java (main app)

⚙️ One-Time Setup

Start everything (build + cache models)

docker compose up --build

🐍 Python (Hugging Face)

Build + run ONLY Python

docker compose up --build python

Restart Python fast (no rebuild)

docker compose restart python

View Python logs

docker compose logs -f python

☕ Java App

Build + run ONLY Java

docker compose up --build java

Restart Java only

docker compose restart java

View Java logs

docker compose logs -f java

🔥 When models keep re-downloading (fix)

Make sure you have a volume:

volumes:
  - hf_cache:/root/.cache/huggingface

🧹 Clean Reset (only if broken)

⚠️ This WILL delete cached models

docker compose down -v
docker compose up --build

⚡ Fast Dev Workflow

Working on Python:

docker compose up python

Working on Java:

docker compose up java

🎯 Pro Tips

  • Use volumes → no rebuild needed for code changes
  • Use --build only when dependencies change
  • Hugging Face cache = HUGE time saver
  • Keep services isolated → faster debugging

✅ Best Daily Commands

# Start one service
docker compose up python

# Rebuild one service
docker compose up --build java

# Check logs
docker compose logs -f

# Restart fast
docker compose restart

🚀 Optional (next level optimization)

If you want even faster builds:

  1. Pre-download model in Dockerfile RUN python -c “from transformers import pipeline; pipeline(‘sentiment-analysis’)”
  2. Use .dockerignore

Avoid sending junk to build:

node_modules
.git
__pycache__