Docker Compose volume not mount for mysql image

2019-03-13T23:55:26

I am trying to create a new Docker image with docker-compose.yml file. Here is my docker-compose.yml file.

version: '3.6'
services:
  php-fpm:
      build:
       context: ./images/php-fpm/
       dockerfile: Dockerfile
      container_name: lempdock_php-fpm_1
      volumes:
        - ./www:/var/www
      depends_on:
        - redis
        - mysql
  nginx:
      build:
        context: ./images/nginx
        dockerfile: Dockerfile
      container_name: lempdock_nginx_1
      ports:
        - "80:80"
        - "443:443"
      volumes:
        - ./www:/var/www
        - ./images/nginx/nginx.conf:/etc/nginx/nginx.conf
        - ./images/nginx/sites/:/etc/nginx/sites-available
        - ./images/nginx/conf.d/:/etc/nginx/conf.d
      external_links:
        - lemp_dock_nginx_1
      depends_on:
        - php-fpm
  mysql:
      build:
        context: ./images/mysql
        dockerfile: Dockerfile
      container_name: lempdock_mysql_1
      restart: always
      volumes:
        - ./data/mysql:/var/lib/mysql
      external_links:
        - lempdock_mysql_1
      ports:
        - "33066:3306"
      expose:
        - 3306
  redis:
      image: redis
      container_name: lempdock_redis_1
      ports:
        - "6379:6379"
      volumes:
        - ./data/redis:/data/redis
      external_links:
        - lempdock_redis_1

This is my folder structure

- /data
---- /mysql
---- /redis
- /images # contain other sub foldes with Dockerfile
- /lemp
-/www # to contain my souce code

As per my docker-compose.yml file, my www folder from root mounted and synced properly with php-fpm and nging docker image, but my mysql data not synced with data/mysql folder.

What I am missing here and How can I get my MySQL data folder mounted to my host computers data/mysql folder?

This is the Github link https://github.com/arifulhb/lempdock if anyone wants to check out this.

Copyright License:
Author:「Ariful Haque」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/55146149/docker-compose-volume-not-mount-for-mysql-image

About “Docker Compose volume not mount for mysql image” questions

I need to mount a disk using docker-compose. Currently I can assemble using docker service create, this way: docker service create -d \ --name my-service \ -p 8888:80 \ --mount='type=volume,dst...
I'm confusing whether it's bind mount or volume mount when using docker-compose for example I think this compose bind mount on host version: "3" services: db: stdin_open: true tty: t
I have the same problem like here Docker - failed to mount local volume, no such file or directory docker-compose --verbose up -d [+] Running 0/0 - Container brickchart-mysql-1 Creating ...
I'm trying to add a volume to the mattermost/mattermost-preview docker image. The Dockerfile for this image (not controlled by me) is: # Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. # ...
Using the official MySQL Docker image, I don't understand how to mount the data directory to a specifc point on the host. The Dockerfile of the image sets VOLUME /var/lib/mysql so database data s...
In the Docker Compose documentation, here, you have the following example related to the volumes section of docker-compose.yml files: volumes: # (1) Just specify a path and let the Engine create a
I use docker-compose for running my containers in docker. I have two services - one of celerybeat and other the web (I have many others but considering only these services because they contain my p...
I mounted local drive as volume for mysql Docker image: mysql: container_name: mysql image: mysql:dev build: ./mysql env_file: .env environment: MYSQL_DATABASE: ${DB_NAME...
I have a Dockerfile I'm pointing at from a docker-compose.yml. I'd like the volume mount in the docker-compose.yml to happen before the RUN in the Dockerfile. Dockerfile: FROM node WORKDIR /us...
I am trying to create a new Docker image with docker-compose.yml file. Here is my docker-compose.yml file. version: '3.6' services: php-fpm: build: context: ./images/php-fpm/

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.