Docker - SQLSTATE[HY000] [2002] No such file or directory

Hey

I’m trying to install docker v5 but for some reason I can’t get access to the database or something.

I’m not really familiar with docker so probably I have something wrong in my docker-compose.yml file.

version: '3.7'

services:
  server:
    image: nginx:alpine
    restart: always
    environment:
      - APP_URL=http://192.168.200.10
    volumes:
      # Vhost configuration
      - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro

      # Configure your mounted directories, make sure the folder 'public' and 'storage'
      # exist, before mounting them
      -  public:/var/www/app/public
      -  storage:/var/www/app/storage
      # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/app/public:/var/www/app/public:rw,delegated
      # - ./docker/app/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - app
    # Run webserver nginx on port 80
    # Feel free to modify depending what port is already occupied
    ports:
      - "8019:80"
      - "44319:443"
    networks:
      - invoiceninja

  app:
    image: invoiceninja/invoiceninja:5
    restart: always
    cap_add:
      - SYS_ADMIN
    environment:
      - APP_URL=http://192.168.200.10
      - APP_KEY=base64:4zsk9mK6uTUS6C1y7OBgjl3n7f2HBYNdihn/V5VMMTE=
      - MULTI_DB_ENABLED=false
      - DB_HOST1=db
      - DB_USERNAME1=ninja
      - DB_PASSWORD1=ninja
      - DB_DATABASE1=ninja
      - PHANTOMJS_PDF_GENERATION=false
    volumes:
      # Configure your mounted directories, make sure the folder 'public' and 'storage'
      # exist, before mounting them
      -  public:/var/www/app/public
      -  storage:/var/www/app/storage
      # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/app/public:/var/www/app/public:rw,delegated
      # - ./docker/app/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - db
    networks:
      - invoiceninja

  db:
    image: mysql:5
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
      - MYSQL_USER=ninja
      - MYSQL_PASSWORD=ninja
      - MYSQL_DATABASE=ninja
    volumes:
      - mysql-data:/var/lib/mysql:rw
      # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/mysql/data:/var/lib/mysql:rw,delegated
    networks:
      - invoiceninja

  # THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5.
  # cron:
  #   image: invoiceninja/invoiceninja:alpine-4
  #   volumes:
  #     -  storage:/var/www/app/storage
  #     -  logo:/var/www/app/public/logo
  #     -  public:/var/www/app/public
  #   entrypoint: |
  #     /bin/sh -c 'sh -s <<EOF
  #     trap "break;exit" SIGHUP SIGINT SIGTERM
  #     sleep 300s
  #     while /bin/true; do
  #       ./artisan ninja:send-invoices
  #       ./artisan ninja:send-reminders
  #       sleep 1d
  #     done
  #     EOF'
  #   networks:
  #     - invoiceninja

volumes:
  mysql-data:
  public:
  storage:
  # This is needed for letting th cron run correctly
  # logo:

networks:
  invoiceninja:

Test test result is:

    SQLSTATE[HY000] [2002] No such file or directory

And docker logs:

server_1  | 10.0.1.4 - - [12/Dec/2020:02:03:57 +0000] "POST /setup/check_db HTTP/1.1" 400 109 "http://192.168.200.10:8019/setup"

app_1     | 172.27.0.4 -  12/Dec/2020:02:03:57 +0000 "POST /index.php" 400

I would use it only for a few invoices. So I don’t need it public.

Thanks in advance
Daniel

Hi,

Sorry, I’m not sure. Maybe the info here will help?

Hey

Thanks for the reply. I just found out!

I hadn’t typed db in Host*. Thought localhost is fine…

Now I need to find out why Custom & Review for Invoice Design doesn’t work under FireFox. But that is only on FireFox. Falkon and Chromium work fine.

I think it’s a bug, I’m seeing the same problem.

We’ll look into it…

Ah ok.
What do I have to do to save the logo? I can upload it but nothing happens.

Are there any errors in the logs in storage/logs?

How can I bind public and storage? I have just created the folder in the root of the docker-compose.yml file.

The only log I can find was with docker-compose logs -f:

"POST /index.php" 200

sudo docker-compose exec app php artisan storage:link

Hm. Nothing has changed.

The [/var/www/app/public/storage] link already exists.
The links have been created.

Do I need to create there the folder there - /var/www/app/public/storage ?. I have created it just in the root folder but nothing seems to work.

No Logo upload possible.

Edit:
Health Check shows me a Config Cache - Warning.

I don’t think you should need to create the folder.

@david or @ben any suggestions?

@Dan @hillel

I haven’t seen this issue in the docker container. My suggestion would be to wipe out and start fresh

For mee too. I think it appears from 5.0.31.

I tried that a few times but I can do it again. Maybe the last update changed anything. I’ll do that tomorrow. GN8

Please let us know about the outcome of this issue.

Thanks.

I started from scratch.

I can’t go through the installation process anymore. There is a “block” because “To proceed to next step, make sure you test each section.”. So I passed PDF, Database and SMTP but I can’t go any further.

@Dan we’ll push out a new release which should fix that issue.

If the fix is included in the latest version, it still does not work.

Edit:
I can go further if I just change it to logs.

Edit2:
Health Check and Logo upload is still the same issue.

@ben have we verified the fixes for the setup screen?

Hey Dan,

We recently pushed the update for the SMTP issue. Make sure you update to the lastest version, please.

Hey

Installation went through with SMTP!

Health Check shows me a Config Cache - Warning.

New issue. I can’t check it:

Error:
Deserializing '[system_health, true, extensions, [{mysqli: true}, {gd: true}, {curl: true}, ...' to 'minified:x8' failed due to: Tried to construct class "HealthCheckResponse" with null field "npmStatus". This is forbidden; to allow it, mark "npmStatus" with @nullable.

No Logo upload possible.

Still the same issue.