I'm trying to create a mysql container, that can use a "volume-from
" a data-only container.I use dockerfile/mysql
, and the data-only volume is from the Dockerfile :
FROM busybox
VOLUME /var/lib/mysql
CMD ["true"]
I can start a simple mysql daemon with docker run -d dockerfile/mysql
, but when connected with a data-only volume,( whether "-v
" with local volume or not ), it'll will fail:
docker create --name box -v {local}:/var/lib/mysql {my-busybox-image}
docker run -d --name db --volume-from box dockerfile/mysql
The docker logs db
message is below
150227 09:56:10 mysqld_safe Logging to syslog.
150227 09:56:10 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150227 09:56:11 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
I use MAC, with boot2docker, and the docker version
is:
Client version: 1.3.0
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): c78088f
OS/Arch (client): darwin/amd64
Server version: 1.5.0
Server API version: 1.17
Go version (server): go1.4.1
Git commit (server): a8a31ef
I have no idea to solve the problem, any tips?
Thanks :)
It's probably because the mysql user doesn't have permission to access the volume.
But there's no need to do it this way. Just use the mysql image to create the volume, then all the permissions will be correct i.e:
docker run --name data-container dockerfile/mysql echo "MySQL data container"
docker run -d --name db --volumes-from data-container dockerfile/mysql
I used run instead of create, in case an entrypoint script needs to run and configure things, but it will exit immediately after the echo. Because you already downloaded the mysql image, your data-container won't be taking up any extra space, so the busybox image wasn't saving you anything.
BTW, dockerfile/mysql
is not the official MySQL image (the official one is just mysql
).