4

I am new to Docker, and now I want to use spateie/laravel-backup package to backup my project and my database.

I need to run the mysqldump command inside of Php container

When I run the mysqldump command inside of DB container, I could use it properly, but I couldn't find this command inside the Php container.

It is my docker-compose.yml :

version: '2'

services:
  project-db:
    image: mariadb:10.3.35
    container_name: project-db
    volumes:
      - ./.configs/mysql_data:/var/lib/mysql
    ports:
      - "3309:3306"
    env_file:
      - ./.configs/.env.setup

  project-nginx:
    image: nginx:stable
    container_name: project-nginx
    volumes:
      - ./workspace/project/:/var/www/project/
      - ./.configs/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    ports:
      - "80:80"
    links:
      - project-php

  project-php:
    build: .
    container_name: project-php
    volumes:
      - ./workspace/project/:/var/www/project/
      - ./.configs/php/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini
    links:
      - project-db
Ebrahim Bashirpour
  • 717
  • 2
  • 10
  • 21
  • 3
    "I need to run the mysqldump command inside of Php container" - why? The command does not exist in the PHP container, unless you install it there. Why not run it from the MySQL container? Also, how is your question related to Laravel itself? – Nico Haase Aug 15 '22 at 08:01
  • 1
    @NicoHaase I'm guessing the `spateie/laravel-backup` package expects the command to be available. _Ed:_ yup ~ https://spatie.be/docs/laravel-backup/v8/requirements – Phil Aug 15 '22 at 08:04
  • 2
    Looking at a package's issue tracker is always worth the mile: https://github.com/spatie/laravel-backup/issues/444 already contains a good solution – Nico Haase Aug 15 '22 at 08:12
  • @Phil , The command to backup is `php artisan backup:run` in this package. but when I tried this command inside the PHP container, I got mysqldump not found. – Ebrahim Bashirpour Aug 15 '22 at 08:14
  • 1
    So, did you try anything to resolve that? The linked issue from the package's issue tracker discusses something that looks pretty similar to your problem – Nico Haase Aug 15 '22 at 08:28
  • @NicoHaase yeah, thanks Nico, After I added `install mariadb-client` to the docker file and my error solved. – Ebrahim Bashirpour Aug 15 '22 at 09:00

0 Answers0