0

I'm trying to set up Docker with my Laravel project on Fedora 30. I want to set up mariadb container. This is from my docker-compose.yml file

mysql-db:
    image: mariadb:10.4.6-bionic
    container_name: mysql-db
    volumes:
      - ./run/var:/var/lib/mysql:Z
    environment:
      - MYSQL_DATABASE=${DB_DATABASE}
      - MYSQL_USER=${DB_USERNAME}
      - MYSQL_PASSWORD=${DB_PASSWORD}
    ports:
      - 3306:3306
    networks:
      backend:
        aliases:
          - db

networks:
  backend:
    name: backend-network

But when I run docker-compose up I get this errors.

mysql-db       | find: '/var/lib/mysql/': Permission denied
mysql-db       | chown: changing ownership of '/var/lib/mysql/': Permission denied
mysql-db exited with code 1

I think it is problem with SELinux, as I had permission denied problems with my php-apache container. And I solved them by adding Z at the end of volumes line. I tried that here too, but it doesn’t seem to work.

  • Hello Danillo, Yes, I had permission problem with php apache container too. I solved this problem this command. Maybe useful. RUN usermod -u 1000 www-data – Emircan Ok Jul 02 '19 at 14:39
  • Thank you very much for your reply, tried something similar, but I'm afraid it didn't work :( – Danilo Petkovic Jul 02 '19 at 14:47
  • I suggest look this post. https://stackoverflow.com/questions/34442831/permission-denied-when-mounting-docker-volume-in-osx – Emircan Ok Jul 02 '19 at 14:54

1 Answers1

0

It looks like I needed to set up value for MYSQL_ROOT_PASSWORD in environment. Now it happens to work :)