Skip to content

Deployment

After the Docker images are loaded and the application is deployed using docker compose, it is crucial to monitor the containers to ensure they are running as expected. This guide provides detailed steps for monitoring and troubleshooting your containers post-deployment.

Deploying the Application

To start the application, use the following commands depending on your operating system:

Bash
cd apifort
docker compose up -d
PowerShell
dir apifort
docker compose up -d
  • The docker compose up -d command will start the application in detached mode, allowing it to run in the background.

Monitoring Containers

After executing the docker compose up -d command, it is essential to monitor the status of your containers to ensure they are running smoothly and to detect any potential issues.

Checking Container Status

To view the status of all containers, use the following command:

Bash
docker compose ps
PowerShell
docker compose ps
  • This command will display a list of all containers along with their current status (e.g., "Up", "Exited", etc.).
  • Look for any containers that are not in the "Up" state, as this may indicate an issue with the deployment.

Viewing Logs

If a container is not running as expected or has exited, you can inspect its logs to identify the root cause of the problem. Use the following command to view logs:

Bash
docker compose logs <service-name>
PowerShell
docker compose logs <service-name>
  • Replace <service-name> with the name of the problematic service.
  • Review the logs for error messages or warnings that might indicate the source of the issue.

Real-Time Log Monitoring

To monitor logs in real-time for all containers, use the following command:

Bash
docker compose logs -f
PowerShell
docker compose logs -f
  • The -f flag allows you to follow the logs as they are being generated.

Troubleshooting Common Issues

  1. Container Exited Immediately:
  2. Use docker compose logs <container_name> to check for errors in the logs.
  3. Verify that all required environment variables are correctly configured in the docker-compose.yml file.

  4. Port Conflicts:

  5. If a container fails to start due to a port conflict, ensure that the ports specified in the docker-compose.yml file are not already in use by another service.

  6. Database Connection Issues:

  7. If the application cannot connect to the database, ensure that:

    • The database container is running and accessible.
    • The credentials in the docker-compose.yml file are correct.
    • The network configuration allows communication between containers.
  8. Resource Limitations:

  9. If containers are restarting frequently, check the system resources (CPU, memory, disk space) using the docker stats command.

  10. Incorrect Configuration:

  11. Ensure that all parameters in the docker-compose.yml file are correctly configured, especially for services like MinIO, PostgreSQL, and the application.

Stopping and Restarting Containers

If you need to stop and restart the containers, use the following commands:

Bash
docker compose down
PowerShell
docker compose down
Bash
docker compose up -d
PowerShell
docker compose up -d

Additional Commands for Container Management

  • View Resource Usage:

    Bash
    docker stats
    
    Use this command to monitor the resource usage (CPU, memory, network) of all running containers in real-time.

  • Inspect Container Details:

    Bash
    docker inspect <container_name>
    
    Use this command to view detailed information about a specific container.


Best Practices for Monitoring

  • Regularly check the status of your containers using docker compose ps.
  • Monitor logs in real-time during critical operations using docker compose logs -f.
  • Ensure that your system has sufficient resources to run all containers smoothly.
  • Address any issues promptly to avoid disruptions to the application.