darkiron
darkiron

Reputation: 1234

Sf3 Docker-compose : [2002] Connection refused

I trie to update my schema in symfony with my docker container.

Have a pdo exception :

[PDOException]
SQLSTATE[HY000] [2002] Connection refused

my docker-compose work thine with phpmyadmin:

version: "3"
services:
   web:
       image: nginx:latest
       ports:
           - "3636:80"
       volumes:
           - .:/code
           - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
       links:
           - php

    php:
        build: ./docker/engine
        links:
            - db:mysql
        volumes:
           - .:/code
    db:
        image: mysql:5.7
        ports:
            - "3306:3306"
        expose:
            - "3306"
        volumes:
            - db_data:/var/lib/mysql
        environment:
            MYSQL_ROOT_PASSWORD: root
            MYSQL_USER: xxx
            MYSQL_PASSWORD: xxx
            MYSQL_DATABASE: xxx

     phpmyadmin:
        image: phpmyadmin/phpmyadmin
        links:
            - db:mysql
        ports:
            - 76:80
        environment:
            MYSQL_USERNAME: root
            MYSQL_ROOT_PASSWORD: root

volumes:
    db_data:

My parameter.yml :

 database_host: db
 database_port: 3636
 database_name: xxx
 database_user: xxx
 database_password: xxx

I don't understand this anymore ! Thx for your help

Upvotes: 1

Views: 726

Answers (2)

0TshEL_n1ck
0TshEL_n1ck

Reputation: 451

Your nginx working on the 3636, db working on the 3306, change database_port in your parameters.yml from 3636 to 3306, if your code live inside Docker - remove

        ports:
        - "3306:3306"

and steel exposes 3306 for MySQL and other services only inside Docker.

Upvotes: 0

Matteo
Matteo

Reputation: 39370

The port exposed and used by the database container is 3306. So in the parameters.yml try

 database_port: 3306

instead of

 database_port: 3636

Hope this help

Upvotes: 1

Related Questions