5

I am learning Docker. Reading a Docker book, it says "it is not recommended run stateful applications (ie databases engines) on Docker". I also heard from a friend of mine that he uses MySQL on Docker with no problems.

Is it good practice to run stateful applications on Docker? What are the scenarios where Docker best fits in?

1 Answer 1

7

The problem with statefull docker aplications is that they by default store their state (data) in the containers filesystem. Once you update your software version or want to move to another machine its hard to retrieve the data from there.

What you need to do is bind a volume to the container and store any data in the volume. This volume might be on the host running the container or somewhere else. This picture explains the different setups.

if you run your container with: docker run -v hostFolder:/containerfolder any changes to /containerfolder will be persisted on the hostfolder. Something similar can be done with a nfs drive. Then you can run you application on any host machine and the state will be saved in the nfs drive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.