What is the best way to store some data in to a container?

I would like to store some data in my container and migrate the container to a remote host with the data.
How data are stored in a container ? could it be in a form of file ? or data objects within the running program ?
My container is a simple java program which processes some data.
Is it possible to store the data as XML file inside the container ?

Just like VM’s, one can create and store files inside VM image and migrate it to another hosts …

Thanks for you advice.

It is advisable to not store persistent data inside containers. The suggested approach is to use Docker volumes(https://docs.docker.com/engine/tutorials/dockervolumes/) and mount volume inside container. When you migrate container to a new host, volumes needs to be moved as well and attached to new container. There are Docker volume plugins available that do the automatic volume management.


Thanks for the reply :slight_smile: