Execute lumen migration using docker

1

I have a'docker-compose.yml' file where I have: MYSQL and php separated in containers.

I enter the container with php, to execute the command'php artisan migrate', in the first instance it tells me that the pdo_mysql driver is missing, that I could solve it, the error that I could not solve is the one that says' SQLSTATE [HY000] [2002] Connection refused '

I leave my'.yml' here to see if I'm missing something or I'm failing something.

version: '2'
services:
  composer:
    container_name: wallet-project-composer
    image: composer
    volumes:
      - .:/app
  database:
    container_name: wallet-project-database
    image: mysql:5.6
    volumes:
      - db_data:/var/lib/mysql
    environment:
      MYSQL_DATABASE: project
      MYSQL_ROOT_PASSWORD: password
  rest:
    container_name: wallet-project-rest
    image: php:7.2
    working_dir: /app
    command: php -S 0.0.0.0:8000 ./api/public/index.php
    ports:
      - 8000:8000
    volumes:
      - .:/app
  phpmyadmin:
    container_name: wallet-project-phpmyadmin
    depends_on:
      - database
    image: phpmyadmin/phpmyadmin
    ports:
      - 8001:80
    environment:
      PMA_HOST: database
      MYSQL_ROOT_PASSWORD: password
volumes: 
  db_data:
  

Everything works wonderfully, the only problem is that.

    
asked by Franklin'j Gil'z 25.12.2018 в 07:07
source

1 answer

1

Is the ip in DB_HOST correct? Check this one in your .env and in database.php ... There goes the ip of the virtual host ... you can see the ip of the virtual host with docker inspect:

According to your docker client it will be:

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id

ó:

docker inspect --format '{{ .NetworkSettings.IPAddress }}' container_name_or_id

Greetings

    
answered by 26.12.2018 / 10:40
source