A
A
Andrey Pushkin2019-04-27 15:07:40
PHP
Andrey Pushkin, 2019-04-27 15:07:40

How to run artisan migration on docker-compose build?

Initialized containers, docker-compose.yml

version: '2'
services:
  nginx:
    build:
      context: ./
      dockerfile: docker/nginx.docker
    volumes:
      - ./:/var/www
    ports:
      - "8080:80"
    links:
      - php-fpm
  php-fpm:
    build:
      context: ./
      dockerfile: docker/php-fpm.docker
    volumes:
      - ./:/var/www
    environment:
      - "DB_PORT=3306"
      - "DB_HOST=mysql"
      - "REDIS_PORT=6379"
      - "REDIS_HOST=redis"
    links:
      - mysql
      - redis
  mysql:
    image: mysql
    volumes:
      - ./storage/docker/mysql:/var/lib/mysql
    environment:
      - "MYSQL_ROOT_PASSWORD=123456"
      - "MYSQL_USER=app"
      - "MYSQL_PASSWORD=123456"
      - "MYSQL_DATABASE=app"
    ports:
      - "33061:3306"
  redis:
    image: redis
    ports:
      - "63791:6379"

The project started everything is OK, but the database is empty. How to execute, from which container, php artisan migrate?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2019-04-27
@a_pussycan

It would be more correct to create a new container from the php-fpm image via docker run and run the command in it as cmd.
It is also possible in an existing one via docker exec.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question