Docker Community Forums

Share and learn in the Docker community.

Docker compose facing issue

Hello Team

I have facing issue in docker compose.

want to generate mysql service having custom config and use existing db that will import in volume.

below is content of docker compose

version: “3”

services:
mydb1:
image: mysql:5.6
#build: ./mysql
#command: --default-authentication-plugin=mysql_native_password
ports:
- 7703:3306
environment:
MYSQL_ROOT_PASSWORD: hardik
MYSQL_DATABASE: legacy
volumes:
- “./mysql/data/:/var/lib/mysql:rw”
- “./mysql/conf.d/my-custom.conf:/etc/mysql/conf.d/custom.conf”

You can’t just mount existing database files into a new server, you have export the data from the old server using mysqldump or some other tool (Percona Xtrabackup, MySQL Enterprise Backup) and then import it into the new one.

Ok got it.

but how can i use custom configuration for mysql container in docker compose.

please share syntax if possible.

thank you.