MySQL image ignores volume configuration of docker-compose.yml
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 should be stored "somewhere" on the host. I want to be more specific in my docker-compose file, so I tried the following:
mysql:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=mydb
volumes:
- ./database/mysql:/var/lib/mysql
Starting with docker-compose up everything works fine, but the ./database/mysql directory on the host stays empty, whereas /var/lib/mysql in the container contains data. Is there a problem in my configuration? Or do I misunderstand how to use volumes?
Copyright License: Author:「Sebastian vom Meer」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer. Link to:https://stackoverflow.com/questions/33087973/mysql-image-ignores-volume-configuration-of-docker-compose-yml
About “MySQL image ignores volume configuration of docker-compose.yml” questions
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...
|
I am trying to learn volume in docker-compose.yml, and I came across this code from this example:
https://docs.docker.com/compose/wordpress/
version: "3.9"
services:
db:
image: mys...
|
I am trying to externalise my runtime data from my applications to be saved in OpenMediaVault shared folder.
I was able to create shared folder and configure NFS or at least I think so. The config ...
|
I have installed Ubuntu using virtual box and also install apt, docker and docker-compose inside it.
Now I want to create MySQL database using docker-compose.yml
In which, i defined MySQL configur...
|
I'm new to Docker and I'm trying to find out how to set the name of the created data volume. Currently the directory is automatically named as a long hash under /var/libs/docker which is far from u...
|
I have a docker-compose.yml from which I started a couple of services. I add a new volume mapping to one of the services and then try to restart the container with
docker compose restart <servic...
|
This message to clear up a problem I am having with the use of docker with my php application.
Indeed, I execute locally my dockers images (nginx, phpmyadmin and php with my application) and every...
|
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/
|
I would like to change an existing docker mysql volume that contains my databases in a container from:
/var/lib/docker/volumes/docker_data
to a shared volume, eg
/mysql_data
but when I change the
|
What's the difference between declaring in the docker-compose.yml file a volume section and just using the volumes keyword under a service?
For example, I map a volume this way for a container:
|
|
|