Most common Docker conmmands:
- Container Management
These commands are used to control the lifecycle of your containers (like php-devblog or nginx-gateway).
docker ps
Lists all running containers.
docker ps -a
Lists all containers, including those that are stopped or crashing (useful for debugging “Restarting” status).
docker stop
Gracefully stops a running container.
docker start
Starts a stopped container.
docker restart
Restarts a container (useful after changing config files like nginx.conf).
docker rm -f
Forces the removal of a container. - Docker Compose (Multi-container Orchestration)
Since you are using a docker-compose.yml file, these will be your most frequently used commands.
docker compose up -d
Starts all services in the background (detached mode). It creates containers, networks, and volumes.
docker compose down
Stops and removes all containers and networks defined in the file.
docker compose logs -f --tail 50
Follows (-f) the live logs of a specific service (e.g., devblog-app) showing only the last 50 lines.
docker compose build --no-cache
Rebuilds your images from scratch (use this after updating your Dockerfile for PHP extensions).
docker compose exec sh
Opens an interactive terminal inside a running container (e.g., to run wp-cli). - System Maintenance & Cleanup
Docker can consume a lot of disk space on your Oracle Linux instance if not managed.
docker system prune
Removes all unused containers, networks, and dangling images.
docker system prune -a --volumes
Nuclear option: Deletes everything not currently in use, including volumes (use with caution!).
docker system df
Shows how much disk space Docker is currently using. - Troubleshooting & Inspection
Use these when something goes wrong (like the “Connection Refused” error).
docker inspect
Returns low-level information about a container (IP address, mounts, environment variables).
docker stats
Displays a live stream of resource usage (CPU, Memory, Network I/O).
docker port
Shows which public ports are mapped to the container. - When noothing working…
recreate all containers
sudo docker compose up -d --force-recreate
- Run command inside container
sudo docker exec nginx-gateway nginx -t
sudo docker exec nginx-gateway nginx -s reload
