This guide provides step-by-step instructions for building images, running containers, stopping them, viewing logs, and managing Docker resources.
Navigate to the folder containing your Dockerfile and docker-compose.yml.
docker-compose buildThis builds two images:
smart-energy-frontendsmart-energy-backend
docker-compose upRun in background:
docker-compose up -dAccess:
- Frontend → http://localhost:5173
- Backend → http://localhost:5000
docker-compose downThis stops and removes containers (not images).
docker psView all containers (running + stopped):
docker ps -adocker imagesRun only frontend:
docker-compose up frontendRun only backend:
docker-compose up backenddocker build -t smart-energy-image .Expose port and run:
docker run -p 5173:5173 smart-energy-imageFind container ID:
docker psThen stop:
docker stop <container_id>docker rm <container_id>docker rmi <image_id>docker-compose restartFrontend logs:
docker-compose logs frontendBackend logs:
docker-compose logs backendFollow logs live:
docker-compose logs -fThis .md file gives you everything needed to work with Docker images and containers efficiently.