Are the containers configured correctly?

Hello,
This is my docker compose file:

services:
  portal-view:
    container_name: Portal-View
    build:
      context: /home/project/portal-view
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=development
      - REACT_APP_API_URL=http://localhost/api
      - BUILDKIT_INLINE_CACHE=0
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
      interval: 1m30s
      timeout: 10s
      retries: 3
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 1G
        reservations:
          cpus: '0.5'
          memory: 512M
    networks:
      - app-network
  
  backend:
    build:
      context: /home/project/portal
      dockerfile: Dockerfiler
    image: php:fpm-alpine3.20
    container_name: Backend
    restart: unless-stopped
    ports:
      - "9000:9000"
    tty: true
    environment:
      SERVICE_NAME: backend
      SERVICE_TAGS: dev
      APP_URL: http://localhost:9000
      DB_HOST: db
      DB_DATABASE: laravel_db
      DB_USERNAME: laravel_user
      DB_PASSWORD: secret
      PHP_MEMORY_LIMIT: 512M
      PHP_MAX_EXECUTION_TIME: 120
    working_dir: /var/www
    volumes:
      - ./:/var/www
    deploy:
      resources:
        limits:
          cpus: '2.0'
          memory: 2G
        reservations:
          cpus: '1.0'
          memory: 1G
    networks:
      - app-network
    depends_on:
      - db
  
  db:
    image: mariadb:latest
    container_name: DB
    restart: unless-stopped
    tty: true
    environment:
      MARIADB_DATABASE: laravel_db
      MARIADB_USER: laravel_user
      MARIADB_PASSWORD: secret
      MARIADB_ROOT_PASSWORD: rootsecret
      TZ: UTC
      MARIADB_INNODB_BUFFER_POOL_SIZE: 512M
      MARIADB_INNODB_LOG_FILE_SIZE: 256M
    volumes:
      - dbdata:/var/lib/mysql/
      - ./mysql/my.cnf:/etc/mysql/my.cnf
#      - ./portal.sql:/docker-entrypoint-initdb.d/import.sql
    deploy:
      resources:
        limits:
          cpus: '2.0'
          memory: 4G
        reservations:
          cpus: '1.0'
          memory: 2G
    networks:
      - app-network
    command: --default-time-zone=UTC --innodb-buffer-pool-size=512M
  
  
  phpmyadmin:
    image: phpmyadmin:latest
    container_name: PhpMyAdmin
    restart: unless-stopped
    environment:
      PMA_HOST: db
      PMA_USER: root
      PMA_PASSWORD: rootsecret
      UPLOAD_LIMIT: 128M
      MEMORY_LIMIT: 256M
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 512M
        reservations:
          cpus: '0.25'
          memory: 256M
    ports:
      - "8080:80"
    networks:
      - app-network
    depends_on:
      - db

networks:
  app-network:
    driver: bridge
    
volumes:
  dbdata:
    driver: local

And Nginx is installed natively on the server. Its configuration is as follows:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /api {
        try_files $uri $uri/ /index.php?$query_string;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/public$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param HTTP_HOST $host;
    }
}

When I go to the server address, the login page is displayed, but when I enter my username and password, nothing happens and no errors are shown.
I did:

$ docker exec -it Backend sh

I can ping all containers.

Where is the problem?

Thank you.

The configuration seems fine from what I can see. At least I don’t see anything that would cause the described behaviour.

What does the developer console in your browser show? Any network requests being made? Any errors in the console?

Also, you could try docker compose logs -f to tail the logs while you log in.

1 Like

Hello,
Thank you so much for your reply.
I guess this is a database connection problem (Docker says "SQLSTATE[HY000] [2002] Connection refused" - #6 by hack3rcon).