Overview
Docker deployment provides a containerized, production-like environment for running the simulator. This method is recommended for evaluation, testing, and consistent deployment across different systems.Prerequisites
- Docker Desktop installed on your system
- Basic familiarity with Docker commands
Dockerfile
The project includes a lightweight Dockerfile that uses Nginx Alpine to serve the static application:- Uses the lightweight
nginx:alpinebase image - Copies all project files to Nginx’s web root
- Exposes port 80 for HTTP traffic
Deployment Steps
Build the Docker image
Build the Docker image with a descriptive tag:This process typically takes less than a minute as the image is very lightweight.
Run the container
Start the container and map port 8080 to the container’s port 80:
The
-p 8080:80 flag maps your local port 8080 to the container’s port 80. You can change 8080 to any available port on your system.Docker Commands Reference
Advanced Options
Running in Detached Mode
To run the container in the background (detached mode):-d flag runs the container in detached mode, and --name gives it a friendly name.
Using Different Ports
If port 8080 is already in use, you can map to a different port:Viewing Container Logs
To view Nginx access logs:-f flag follows the log output in real-time.
Benefits of Docker Deployment
Consistency
Runs identically on any system with Docker
Isolation
Contained environment doesn’t affect your system
Production-Ready
Uses Nginx, a production-grade web server
Easy Cleanup
Remove everything with a single command
Troubleshooting
Port already in use
Port already in use
If you see an error about port 8080 being in use, either:
- Stop the application using that port
- Use a different port:
docker run -p 3000:80 algoritmos-planificacion
Docker daemon not running
Docker daemon not running
Ensure Docker Desktop is running. On macOS/Windows, check the system tray for the Docker icon.
Permission denied errors (Linux)
Permission denied errors (Linux)
On Linux, you may need to run Docker commands with Then log out and back in.
sudo, or add your user to the docker group:Build fails
Build fails
Ensure you’re in the correct directory containing the Dockerfile: