Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker connect phpmyadmin to my MySQL Server

Hello im trying to connect mysql to my phpmyadmin container how can i bind the mysql to this. is it also possible to change the port 8080 to /phpmyadmin im access to http://192.168.99.100:8080 so i get http://192.168.99.100/phpmyadmin instead of the container id

version: '2'
services:
  #######################################
  # PHP application Docker container
  #######################################
  app:
    build:
      context: .
      dockerfile: Dockerfile
    links:
      - mysql
    ports:
      - "8000:80"
    volumes:
      - ./app/:/app/
      - ./:/docker/
    volumes_from:
      - storage
    networks:
      - php-network
#######################################
# MySQL server
#######################################
  mysql:
    build:
      context: docker/mysql/
      dockerfile: MySQL-5.7.Dockerfile
    restart: always
    volumes_from:
      - storage
    env_file:
      - etc/environment.yml
    networks:
    - php-network
#######################################
# PHP MY ADMIN
#######################################
  myphpadmin:
    build:
      context: docker/myphpadmin
      dockerfile: Dockerfile
    restart: always
    links:
    - mysql
    ports:
    - 8080:80
    environment:
    - PMA_ARBITRARY=1
    networks:
    - php-network

  storage:
    build:
      context: docker/storage/
    volumes:
      - /storage

networks:
    php-network:
      driver: bridge
like image 405
mY777 Avatar asked Sep 14 '25 20:09

mY777


1 Answers

You will have to specify 2 more variables inside your docker-compose file under the phpmyadmin service:

environment:
  PMA_HOST: mysql
  PMA_PORT: 3306

Because even though you have created the link between your phpmyadmin and mysql containers, the phpmyadmin container will look for a database on 'localhost'

like image 165
Sergiu Avatar answered Sep 17 '25 10:09

Sergiu