Search code examples
mysqldockerpodman

Podman connection error: 2003, "Can't connect to MySQL server on 'mysql:3306'


Hi I am trying to use podman instead of docker for first time, as all things was working well by using docker, when I run the same image using podman I get this connection error:

2003, "Can't connect to MySQL server on 'mysql:3306'

Well I tried connecting to database with the host device and it worked, but it's the misp container which isn't connecting to DB.

This is the docker-compose.yml:


version: '3.3'

services:
  mysql:
    image: mariadb:10.8.2
    restart: always
    container_name: misp-mysql
    tmpfs:
      - /tmp
    environment:
      MYSQL_DATABASE: misp
      MYSQL_USER: misp
      MYSQL_PASSWORD: password
      MYSQL_ROOT_PASSWORD: password
    ports:
      - 3306:3306
  redis:
    image: redis:7.0
    restart: always
    container_name: misp-redis

  misp-modules:
    image: ghcr.io/nukib/misp-modules:latest
    restart: always
    container_name: misp-modules
    cap_drop:
      - NET_RAW
      - SYS_CHROOT
      - MKNOD
      - NET_BIND_SERVICE
      - AUDIT_WRITE
      - SETFCAP

  misp:
    image: ${MISP_IMAGE-ghcr.io/nukib/misp:latest}
    restart: always
    container_name: misp
    depends_on:
      - mysql
      - redis
    links:
      - mysql
    tmpfs:
      - /tmp
    cap_drop:
      - NET_RAW
      - SYS_CHROOT
      - MKNOD
      - AUDIT_WRITE
      - SETFCAP
    environment:
      MYSQL_HOST: mysql:3306
      MYSQL_LOGIN: misp
      MYSQL_PASSWORD: password # Please change for production
      MYSQL_DATABASE: misp
      REDIS_HOST: redis
      MISP_BASEURL: http://localhost:8080
      MISP_UUID: 0a674a5a-c4cb-491d-80cf-5adb48b5c1cd # Please change for production
      MISP_ORG: Testing org # Please change for production
      MISP_MODULE_URL: http://misp-modules
      MISP_EMAIL: ahoj@example.com # Please change for production
      SECURITY_SALT: PleaseChangeForProduction # Please change for production
      ZEROMQ_ENABLED: "yes"
    ports:
      - 8080:80
      - 50000:50000


This is the CLI command used in the dockerEntryPoitn.sh


    # Create database schema
    su-exec apache misp_create_database.py $MYSQL_HOST $MYSQL_LOGIN $MYSQL_DATABASE /var/www/MISP/INSTALL/MYSQL.sql

GitHub URL: https://github.com/NUKIB/misp


Solution

  • Try installing podman-plugins. No indications that you need to install this but this solved my similar problem of containers not being able to reach each other by their service name.

    Containers created with docker-compose are not able to connect to each other by using their name