Docker – Extending official images

In one of our projects we provide our developers a mysql container for the local development environment pre-seeded with tables and data so the app will work “out of the box“. Previously we built the mysql container from a raw ubuntu image but now that there is a official mysql image on the docker hub I wanted to change to use it instead. i.e. I wanted to start our Dockerfile with FROM mysql. I ran into a issue. The official image uses VOLUME /var/lib/mysql so any mysqld data we add in our child container doesn’t persist the build. This occurs because Volumes don’t use the layered filesystem – the docker ISSUE is tracked in

There are lots of workarounds, but the one I chose was to modify our mysql container to use a different datadir (e.g. /var/lib/mysql2) so it is not clobbered by the official image. This was the resulting Dockerfile:

The same problem occurs for the official mongo container, and I used the same solution:

I found for the mongo hack to work I had to start the container with: mongod --config /etc/mongodb.conf


Tags >

No Comment

Post A Comment