0

I am not sure if this is a bug, or a feature. But I have been running this docker-compose setup for my local development databases several months now and since I have updated Docker and Lando it stopped working.

As you can see I use it for some php sites managed with Lando. Since the last update either the ports or the network directive is not working on the MySQL container.

  • If I use it with the snippet below the ports directive is not working. Meaning I can not connect from QueryPie on localhost:3306, but can connect from another lando docker container with mysql_db as host.
  • If I comment out the networks directive, the ports directive is working. But the networks directive obviously not. Meaning I can connect from QueryPie on localhost:3306, but I can not connect from another lando docker container with mysql_db as host.

Before the update they worked nice together. So I could open MySQL in QueryPie and access the databases from the Lando containers.

version: '3'
services:
  mysql:
    container_name: mysql_db
    restart: always
    image: mysql:latest
    ports: 
        - "3306:3306" 
    environment:
       - MYSQL_ROOT_PASSWORD=secret
    volumes:
      - ./mysql-data:/var/lib/mysql
    networks:
      - lando_bridge_network
networks:
  lando_bridge_network:
    external: true

My docker engine is 19.03.8 and my docker-compose version is 1.25.5.

Florian
  • 725
  • 6
  • 27
  • 2
    You've shown two database configurations; where are the clients to these databases running? What's the actual problem you're encountering? The `postgres` container is on the Compose-provided `default` network and not the external network, is that a problem for you? – David Maze Apr 29 '20 at 17:34
  • No that is actually not a problem. The postgres container is available for the host and doesn't need to be available for other docker containers. – Florian Apr 30 '20 at 06:57

1 Answers1

0

So I solved it by removing the networks directive and only exposing port 3306 with ports. The PHP sites running on lando/docker I the internal docker IP to connect:

define('DB_HOST', 'host.docker.internal');

In QueryPie (running on the host) I can connect with localhost:3306

version: '3'
services:
  mysql:
    container_name: mysql_db
    restart: always
    image: mysql:latest
    ports: 
        - "3306:3306" 
    environment:
       - MYSQL_ROOT_PASSWORD=secret
    volumes:
      - ./mysql-data:/var/lib/mysql
Florian
  • 725
  • 6
  • 27