J
J
Julia Kovalenko2017-05-03 10:27:26
MySQL
Julia Kovalenko, 2017-05-03 10:27:26

How to run mysql in a docker container with data from the host?

I downloaded the image from https://hub.docker.com/_/mysql/ .
I already have mysql on the host. The versions on the host and in the image are the same. I want to run in mysql container with data from host.
I start the container like this:

sudo docker run --name my-mysql -v /var/lib/mysql:/var/lib/mysql -it mysql bash

Everything is successfully mounted into the container and I see all the data of all tables. But mysql won't start.
Trying to do:
028c647419f64ba8ba84a6357b2cb9ea.png
Mysql seems to hang. This is how he starts drawing dots for me. How to do it anyway?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Kudryavtsev, 2017-05-03
@kumaxim

Do you want two MySQL servers to read the same table files?
So that two servers simultaneously overwrite each other's data?
So that two servers climb into the same files with different meta-data?
Some kind of nonsense turns out ....
If you need a copy of all tables / data / users, then set up replication between your host and the docker container.
Perhaps you need to get from the application in the docker container to the DBMS on the host?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question