T
T
thisall2021-02-18 14:44:23
Docker
thisall, 2021-02-18 14:44:23

How to run MySQL through Docker?

Please tell me, I am running a separate phpmyadmin + mysql container, how can I connect other containers to the container with phpmyadmin + mysql

docker-compose-yml (Container for Laravel)

version: '3'

services:
  app:
    container_name: dev.doment.ru
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ./production/php/local.ini:/usr/local/etc/php/conf.d/local.ini
    networks:
      - yelm-service

  composer:
    container_name: composer
    image: composer
    command: /bin/bash "/app/commands/production/start-composer.sh"
    volumes:
      - ./:/app
    networks:
      - yelm-service

  npm:
    container_name: npm
    image: node:14.1.0-slim
    command: /bin/bash "/var/www/containers/dev/commands/production/start-npm.sh"
    volumes:
      - ./:/var/www/containers/dev
    networks:
      - yelm-service

  nginx:
    container_name: nginx
    image: nginx:alpine
    ports:
      - 8081:80
    volumes:
      - ./:/var/www/containers/dev
      - ./production/nginx/conf.d/:/etc/nginx/conf.d/
    networks:
      - yelm-service

networks:
  yelm-service:

volumes:
  data:
    driver: local


docker-compose-yml (Container for PhpMyAdmin and MySQL)

version: "3.7"

services:

  mysql:
    image: mysql:8.0.19
    container_name: mysql
    volumes:
      - ./mysql:/var/lib/mysql
    networks:
      - yelm-service
    environment:
      MYSQL_ROOT_PASSWORD: RecodeGET200

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:5.0.4
    container_name: phpmyadmin
    restart: always
    networks:
      - yelm-service
    ports:
      - "8080:80"
    environment:
      PMA_HOST: mysql
    depends_on:
      - mysql

networks:
  yelm-service:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2021-02-18
@thisall

Add external to the network definition:
https://tjtelan.com/blog/how-to-link-multiple-dock...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question