Docker Community Forums

Share and learn in the Docker community.

How to use local mysql instance on docker compose?

dockerhub
docker

(Sivasubramanian1) #1

I have a docker-compose file like this:
version: "3.1"
services:

mysql:
  image: mysql:5.7
  container_name: mysql
  working_dir: /application
  volumes:
    - .:/application
  environment:
    - MYSQL_ROOT_PASSWORD=password
    - MYSQL_DATABASE=DB
    - MYSQL_USER=USER
    - MYSQL_PASSWORD=password
  ports:
    - "1027:3306"

webserver:
  image: nginx:alpine
  container_name: webserver
  working_dir: /application
  volumes:
      - .:/application
      - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
  ports:
   - "80:80"

php-fpm:
  build: phpdocker/php-fpm
  container_name: php-fpm
  working_dir: /application
  volumes:
    - .:/application
    - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php5/fpm/conf.d/99-overrides.ini

Is it possible to connect to local mysql instance instead of docker instance in PHP?