1

Trying to run laravel via docker containers. So, isolated containers include artisan, mariadb, phpfpm, phpmyadmin, data, and storage containers.

These containers are connected via links, the data container stores laravel files, and the storage container is meant to store the database files; thus, both act as the volume to other containers.

The mariadb container runs of the stock mariadb container provided on the docker hub repository. Artisan and phpfpm containers are based on the image provided by dylanlindgren on the docker hub repository.

The artisan container is linked to the db container, with the following command:

docker run --privileged=true --volumes-from myapp-data  --link myapp-db --rm ayoolaosun/docker-laravel-artisan. 

However, when running the artisan migrate command, the following error pops up:

"PDOException SQLSTATE[HY000] [2002] No such file or directory". 

I recently learnt about containers and am very new to devOps, so I am not sure what to tweak in the containers to solve the problem. Thanks, any tips will do.

Robert Columbia
  • 6,313
  • 15
  • 32
  • 40
dev_a.y
  • 133
  • 2
  • 7
  • Did you or did someone else create this aggregated docker setup? If so what docker image are you using? Some more information on that would be useful – Jonathan Jun 16 '16 at 22:58
  • Well, your errors already gave you a hint - your app is trying to connect to MySQL using a socket file, which is obviously impossible considering they are running in different containers. Just fix your database config (of Laravel) – Denis Mysenko Jun 16 '16 at 23:22
  • 3
    Thanks, fixed the issue by obtaining the db container's IP address using the dockers 'inspect' command. The provided IP address is then applied as the host in Laravel's database config file. – dev_a.y Jun 17 '16 at 05:25
  • 1
    The comment above helped me to know that I was needing to get the DB container's IP address and place it into the Laravel's .env for mysql settings. – Carlos Bensant Sep 18 '16 at 17:10

0 Answers0