Docker Community Forums

Share and learn in the Docker community.

Access container via its name


(Marcoedoapp) #1

I’m setting up two containers: mariadb + phpMyAdmin. I’d like to reach mariadb instance via PMA login. I don’t want to type mariadb container ip, but it’s name or alias. How can I do that, avoiding direct linking to that?

version: '3'
services:
  pma:
    image: phpmyadmin/phpmyadmin
    container_name: pma
    ports:
      - '80:80'
    environment:
      - PMA_ARBITRARY=1
    restart: always
    network_mode: bridge
  mariadb:
    image: mariadb
    container_name: mariadb
    ports:
      - '3306:3306'
    environment:
      - MYSQL_ROOT_PASSWORD=toor
    volumes:
      - '.database:/var/lib/mysql'
    restart: always
    network_mode: bridge

I’ve tried setting up a custom bridge network and it seems to work, but I don’t really need nothing else than the default bridge network.
In the above configuration, phpMyAdmin instance is not pinging “mariadb” host…


(Sam) #2

note that mariadb, like mysql, and mongo by default, ONLY allow an application on the SAME OS

this means the application would have to be INSIDE the mariadb container. (which its not)

see https://mariadb.com/kb/en/library/configuring-mariadb-for-remote-client-access/