Building db image from docker-compose gives error

Hey folks,

I am trying to set up the automated backups and have uncommented the lines for the db image to be built as well as the volumes required.

When I run docker-compose I get the below error when building the db image.

I have included my docker-compose file as well.

Any help is appreciated.

 => [internal] load build definition from Dockerfile                                                                                           0.0s
 => => transferring dockerfile: 324B                                                                                                           0.0s
 => [internal] load .dockerignore                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/mysql:8                                                                                     2.6s
 => CACHED [1/3] FROM docker.io/library/mysql:8@sha256:c0455ac041844b5e65cd08571387fa5b50ab2a6179557fd938298cab13acf0dd                        0.0s
 => => resolve docker.io/library/mysql:8@sha256:c0455ac041844b5e65cd08571387fa5b50ab2a6179557fd938298cab13acf0dd                               0.0s
 => ERROR [2/3] RUN apt-get update;                                                                                                            0.4s
------
 > [2/3] RUN apt-get update;:
#0 0.296 /bin/sh: apt-get: command not found
------
failed to solve: executor failed running [/bin/sh -c apt-get update;]: exit code: 127
version: '3.7'

services:
  server:
    image: nginx
    restart: always
    env_file: env
    volumes:
      - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
      - ./docker/app/public:/var/www/app/public:ro
    depends_on:
      - app
    ports:
      - "8980:80"
    networks:
      - invoiceninja

  app:
    image: invoiceninja/invoiceninja:5
    env_file: env
    restart: always
    volumes:
      - ./config/hosts:/etc/hosts:ro
      - ./docker/app/public:/var/www/app/public:rw,delegated
      - ./docker/app/storage:/var/www/app/storage:rw,delegated
      - ./config/php/php.ini:/usr/local/etc/php/php.ini
      - ./config/php/php-cli.ini:/usr/local/etc/php/php-cli.ini

    depends_on:
      - db
    networks:
      - invoiceninja

  db:
    build:
      context: ./config/mysql
    ports:
      - "3305:3306"
    restart: always
    env_file: env
    volumes:
      - ./docker/mysql/data:/var/lib/mysql:rw,delegated
      - ./docker/mysql/bak:/backups:rw
      - ./config/mysql/backup-script:/etc/cron.daily/daily:ro
      - ./config/mysql/backup-script:/etc/cron.weekly/weekly:ro
      - ./config/mysql/backup-script:/etc/cron.monthly/monthly:ro
    networks:
      - invoiceninja

networks:
  invoiceninja:

Hi,

I don’t have much experience with Docker, you may want to create an issue on the Dockerfile GitHub repo.

Hi, I ran into the same problem since I want to use automatic backups of the database.

It seems, that the package mysql:8 is not Debian- or Ubuntu-based, so there’s simply no apt-software in this image to download things.

However, switching to mysql:8-debian does not help at all. It tries to download a file which cannot be confirmed by gpg, because the needed key is absent. Even if one tries to install the key by the docker-file, the script ends up with another error.

I think I will install the old fashioned docker-image without the automatically built backup-script. I think I’m going to use this as a template to write my own, systemd-based backup-script which runs on the Docker-machine itself.

I guess the Docker-Compose-files need an update. :wink: