How to recover from deleted docker image

Hi All,
I have invoiceplane installed in a docker container(s).

I had the misfortune of doing a docker cleanup and now invoiceplane will not work. I ran:

sudo docker system prune -a --volumes

I though I had invoiceplane containers running, but maybe not, as they looked to be removed. The above removes all but running containers.

I brought all the containers down, and when bringing them up, it seemed to do a reinstall. Or it could be an upgrade …?

The error I get on the main web page is:

A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: core/User_Controller.php

Line Number: 29

I also cannot get into the phpmyadmin to restore the database (I have a backup)

The error on mypmyadmin is:
mysqli::real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo for db failed: No address associated with hostname

I am stuck. Can anyone please help …

There is no container with the name ‘db’ or it has a different ip address.

At the moment are your containers running?
Can you show the output of docker ps

The fact that you have a backup will resolve your problems, so that’s awesome
.
Did you create your own containers? Or are you using something like laradock?
I remember giving you some hints last time

Hi UnderDog, I am using a composer stack of 4 containers …
The output of docker ps is:

cdee57d723d1   ip-nginx                              "/docker-entrypoint.…"   17 hours ago    Up 17 hours   443/tcp, 0.0.0.0:8085->80/tcp, :::8085->80/tcp                                                                                                                                           invoiceplane-nginx
8bbec90dd527   ip-phpmyadmin                         "/docker-entrypoint.…"   17 hours ago    Up 17 hours   0.0.0.0:8081->80/tcp, :::8081->80/tcp                                                                                                                                                    invoiceplane-dbadmin
bc2d40ebb359   ip-php                                "docker-php-entrypoi…"   17 hours ago    Up 17 hours   9000/tcp                                                                                                                                                                                 invoiceplane-php

It seems the db container is not running … the relavent poart of the compose file is:

 # --- MariaDB 10.9
  db:
    container_name: "invoiceplane-db"
    build:
      context: ./resources/docker/mariadb
    environment:
      - MARIADB_ROOT_PASSWORD=ipdevdb
      - MARIADB_USER=ipdevdb
      - MARIADB_PASSWORD=ipdevdb
      - MARIADB_DATABASE=invoiceplane_db
    ports:
      - "3306:3306"
    networks:
      invoiceplane:
        ipv4_address: 172.25.0.13
    volumes:
      - "invoiceplane-db:/var/lib/mysql"

It tries to start but doesn’t say running …

Just wondering if I should create a completely new build from here:
git clone https://github.com/InvoicePlane/InvoicePlane.git

I presume I can restore the database into that new version?

EDIT: I tried the above, and now I have all 4 containers running, however, when I log into the web page I get just a blank white page ??

EDIT2: I shut down all containers and bring them up again, and now the db container is not showing as running again.

Why is this so hard?

1 Like

Debugging this “new” installation. On startup I get:

invoiceplane-db       | 2024-07-08 23:00:52+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.8+maria~ubu2204 started.
invoiceplane-db       | 2024-07-08 23:00:52+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup///memory.pressure not writable, functionality unavailable to MariaDB
invoiceplane-db       | 2024-07-08 23:00:52+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
invoiceplane-db       | 2024-07-08 23:00:52+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.8+maria~ubu2204 started.
invoiceplane-db       | 2024-07-08 23:00:53+00:00 [Note] [Entrypoint]: Initializing database files
invoiceplane-db       | 2024-07-08 23:00:53 0 [Warning] mariadbd: io_uring_queue_init() failed with ENOMEM: try larger memory locked limit, ulimit -l, or https://mariadb.com/kb/en/systemd/#configuring-limitmemlock under systemd (262144 bytes required)
invoiceplane-db       | 2024-07-08 23:00:53 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
invoiceplane-db       | 2024-07-08 23:00:53 0 [ERROR] InnoDB: File ./ib_logfile0 was not found
invoiceplane-db       | 2024-07-08 23:00:53 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
invoiceplane-db       | 2024-07-08 23:00:53 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
invoiceplane-db       | 2024-07-08 23:00:53 0 [Warning] 'default-authentication-plugin' is MySQL 5.6 / 5.7 compatible option. To be implemented in later versions.
invoiceplane-db       | 2024-07-08 23:00:53 0 [ERROR] Unknown/unsupported storage engine: InnoDB
invoiceplane-db       | 2024-07-08 23:00:53 0 [ERROR] Aborting
invoiceplane-db       | 
invoiceplane-db       | Installation of system tables failed!  Examine the logs in
invoiceplane-db       | /var/lib/mysql/ for more information.
invoiceplane-db       | 
invoiceplane-db       | The problem could be conflicting information in an external
invoiceplane-db       | my.cnf files. You can ignore these by doing:
invoiceplane-db       | 
invoiceplane-db       |     shell> /usr/bin/mariadb-install-db --defaults-file=~/.my.cnf
invoiceplane-db       | 
invoiceplane-db       | You can also try to start the mariadbd daemon with:
invoiceplane-db       | 
invoiceplane-db       |     shell> /usr/sbin/mariadbd --skip-grant-tables --general-log &
invoiceplane-db       | 
invoiceplane-db       | and use the command line tool /usr/bin/mariadb
invoiceplane-db       | to connect to the mysql database and look at the grant tables:
invoiceplane-db       | 
invoiceplane-db       |     shell> /usr/bin/mariadb -u root mysql
invoiceplane-db       |     MariaDB> show tables;
invoiceplane-db       | 
invoiceplane-db       | Try '/usr/sbin/mariadbd --help' if you have problems with paths.  Using
invoiceplane-db       | --general-log gives you a log in /var/lib/mysql/ that may be helpful.
invoiceplane-db       | 
invoiceplane-db       | The latest information about mysql_install_db is available at
invoiceplane-db       | https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
invoiceplane-db       | You can find the latest source at https://downloads.mariadb.org and
invoiceplane-db       | the maria-discuss email list at https://launchpad.net/~maria-discuss
invoiceplane-db       | 
invoiceplane-db       | Please check all of the above before submitting a bug report
invoiceplane-db       | at https://mariadb.org/jira
invoiceplane-db       | 

The db exits with code 1 shortly after

In my original installation the db exits with a different reason:

invoiceplane-db       | 2024-07-08 23:08:08+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.4.2+maria~ubu2404 started.
invoiceplane-db       | 2024-07-08 23:08:08+00:00 [ERROR] [Entrypoint]: mariadbd failed while attempting to check config
invoiceplane-db       | 	command was: mysqld --verbose --help
invoiceplane-db       | 	/usr/local/bin/docker-entrypoint.sh: line 105: mysqld: command not found
invoiceplane-db exited with code 1

Ok, let’s focus on that db container.
Stop all containers
Edit the mariadb Dockerfile
./resources/docker/mariadb
The version of MariaDB, it shouldsay something like 10.4.10, and definitely not latest or something like that

Keep doing docker-compose up db so that only mariadb goes up.

docker-compose up db
will only let mariadb go up
If it kills itself we’re not done yet.
When it shows no errors that means it’s running (you shouldn’t see your server’s prompt)

After it’s running you can go docker-compose up -d as you were used to.

If it keeps stopping do:
docker-compose up --build db
It should rebuild the container, since you changed the mariadb version.

Focus on this bit:

invoiceplane-db       | Installation of system tables failed!  Examine the logs in
invoiceplane-db       | /var/lib/mysql/ for more information.
invoiceplane-db       | 
invoiceplane-db       | The problem could be conflicting information in an external
invoiceplane-db       | my.cnf files. You can ignore these by doing:
invoiceplane-db       | 
invoiceplane-db       |     shell> /usr/bin/mariadb-install-db --defaults-file=~/.my.cnf
invoiceplane-db       | 
invoiceplane-db       | You can also try to start the mariadbd daemon with:
invoiceplane-db       | 
invoiceplane-db       |     shell> /usr/sbin/mariadbd --skip-grant-tables --general-log &
invoiceplane-db       | 

After that we’ll be working on this bit:

    volumes:
      - "invoiceplane-db:/var/lib/mysql"

Hi,

Thanks for that. I changed the mariadb version from latest to 10.4.10, and then re-built it as you said. Now it says:

 ✔ Container invoiceplane-db  Created                                                                                                                                                                        0.0s 
Attaching to invoiceplane-db
invoiceplane-db  | 2024-07-10 09:59:17+12:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.10+maria~bionic started.
invoiceplane-db  | 2024-07-10 09:59:17+12:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
invoiceplane-db  | 2024-07-10 09:59:17+12:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.10+maria~bionic started.
invoiceplane-db  | 2024-07-10 09:59:18+12:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
invoiceplane-db  | 	You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
invoiceplane-db exited with code 1

What do I do next? By the way, I am in New Zealand (though Dutch decent :slight_smile: )so timezones are going to be a pain.
By the way where is the database stored? If it is in the cloed folder then my data could be still ok, as it was only the docker images/containers that where deleted … please let me know when you are around, so we can do this together, it will be night time here, but I need to get it sorted …
Thanks

1 Like

Ah, New Zealand, cool. I’m a night person so i’ll help ypu out a bit.

This time i’m guessing since i won’t be working on Docker until this weekend.

Open docker-compose.yml
Add:

      - MYSQL_ROOT_PASSWORD=ipdevdb
      - MYSQL_DATABASE=invoiceplane_db
      - MYSQL_USER=ipdevdb
      - MYSQL_PASSWORD=ipdevdb

Explanation:
By adding MARIADB_ variables, the prompt still errors out about not having users and passwords, etc, so we’ll use MYSQL_ variables even though we’re using MariaDB

Now rebuild please and show the results.

Well… that database was a volume so i don’t think it’s there anymore

For your volume try this:

volumes:
      - "/home/underdog/ipdata:/var/lib/mysql"

It literally stores data in a directory and yes, then you’ll have proper MySQL data locally on your PC.

But it’s still a total pain to get previously stored MySQL data to work with newly installed Docker container.

Please make proper backups through phpMyAdmin or with a nice mysqldump command

I already had those in the docker-compose.yml, stll get the same error:

invoiceplane-db  | 	You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD

I am working on a server, so volume is a server directory … and I do have a backup made with phyMyAdmin … so once we get the database up, hopefully you can help me restore it …

Show your docker-compose.yml
Destroy your db container and rebuild

version: "3"

networks:
  invoiceplane:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.25.0.0/17

volumes:
  invoiceplane-db:
    driver: "local"
  nginx_logs:
    driver: "local"

services:
  # --- PHP 8.1
  php:
    container_name: "invoiceplane-php"
    build:
      context: ./resources/docker/php-fpm
      args:
        - PUID=1000
        - PGID=1000
        - TZ=Pacific/Auckland
    links:
      - db
    expose:
      - "9000"
    dns: 8.8.8.8
    depends_on:
      - db
    networks:
      invoiceplane:
        ipv4_address: 172.25.0.11
    volumes:
      - .:/var/www/projects/invoiceplane:delegated
      - ./resources/docker/php-fpm/php-dev.ini:/usr/local/etc/php/php.ini

  # --- nginx 1.23
  nginx:
    container_name: "invoiceplane-nginx"
    build:
      context: ./resources/docker/nginx
    links:
      - php
    ports:
      - "8085:80"
    dns: 8.8.8.8
    depends_on:
      - php
    networks:
      invoiceplane:
        ipv4_address: 172.25.0.12
    volumes:
      - .:/var/www/projects/invoiceplane:delegated
      - nginx_logs:/var/log/nginx
      - ./resources/docker/nginx/invoiceplane.conf:/etc/nginx/conf.d/invoiceplane.conf:ro

  # --- MariaDB 10.9
  db:
    container_name: "invoiceplane-db"
    build:
      context: ./resources/docker/mariadb
    environment:
      - MARIADB_ROOT_PASSWORD=ipdevdb
      - MARIADB_USER=ipdevdb
      - MARIADB_PASSWORD=ipdevdb
      - MARIADB_DATABASE=invoiceplane_db
    ports:
      - "3306:3306"
    networks:
      invoiceplane:
        ipv4_address: 172.25.0.13
    volumes:
      - "invoiceplane-db:/var/lib/mysql"

  phpmyadmin:
    container_name: "invoiceplane-dbadmin"
    build:
      context: ./resources/docker/phpmyadmin
    environment:
      - PMA_HOST=invoiceplane-db
      - PMA_USER=root
      - PMA_PASSWORD=ipdevdb
      - PMA_ROOT_PASSWORD=ipdevdb
      - MYSQL_DATABASE=invoiceplane_db
      - MYSQL_USER=ipdevdb
      - MYSQL_PASSWORD=ipdevdb
      - MYSQL_ROOT_PASSWORD=ipdevdb
      - MAX_EXECUTION_TIME=600
      - MEMORY_LIMIT=256M
      - UPLOAD_LIMIT=2G
    depends_on:
      - db
    links:
      - db
    restart: always
    volumes:
      - ./resources/docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
      - ./resources/docker/databases:/var/www/html/tmp/upload_databases
    ports:
      - "8081:80"
    networks:
      invoiceplane:
        ipv4_address: 172.25.0.16

How do I destroy container ?
Never mind. I stopped container and removed, then rebuilt, same error…

    environment:
      - MARIADB_ROOT_PASSWORD=ipdevdb
      - MARIADB_USER=ipdevdb
      - MARIADB_PASSWORD=ipdevdb
      - MARIADB_DATABASE=invoiceplane_db

^^^ that is wrong and it should be something else, see my previous messages.

Also check the error message that your db container gave you about missing variables

    volumes:
      - "invoiceplane-db:/var/lib/mysql"

That ^^^ I would change to a real directory like /home/underdog/ipdata

With invoiceplane-db as a volume you’ll keep guessing where your data is stored, just like long time ago.
With a real server directory on your Linux server you actually know where it is stored.

I don’t have any more time today to help you.

I’ll try to drop my work this weekend and make a video for you to make things more clear

1 Like