Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

429
Views
How to migrate to db on docker (Symfony)?
version: '3'

services:
    db:
        image: mysql:8.0.20
        command: --default-authentication-plugin=mysql_native_password
        volumes:
            - "db_app:/var/lib/mysql"
        environment:
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
            MYSQL_DATABASE: ${MYSQL_DATABASE}
            MYSQL_USER: ${MYSQL_USER}
            MYSQL_PASSWORD: ${MYSQL_PASSWORD}
        ports:
            - 3306:3306
        networks:
            - symfony
    php:
        build:
            context: .
            dockerfile: docker/php/Dockerfile
            args:
                TIMEZONE: ${TIMEZONE}
        volumes:
            - ./symfony/:/Users/admin/Downloads/symfony-docker-master/symfony
        networks:
            - symfony
    nginx:
        build:
            context: .
            dockerfile: docker/nginx/Dockerfile
        volumes:
            - ./symfony/:/Users/admin/Downloads/symfony-docker-master/symfony
        ports:
            - 8050:8050
        networks:
            - symfony

volumes:
    db_app:

networks:
    symfony:

The application starts, connects to the database via

DATABASE_URL=mysql://user:123@db:3306/db

But when performing migrations through the console, I get the error

An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddr  
  esses: getaddrinfo failed: nodename nor servname provided, or not known

As I understand it, due to the fact that the address is specified in the connection db.

How to make migrations?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You need to run console commands from inside of your php container

docker-compose exec php bin/console doctrine:migrations:migrate
over 4 years ago · Santiago Trujillo Report

0

You should connect to the container name.

These can be found by running docker container ls on your console.

It's easier when you specify the name in your compose file like so:

services:
    db:
        container_name: db # This can be anything
        image: mysql:8.0.20
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!