Initialize docker volume ony once
I would like to initialize a docker volume only after it has been created, not each time a container is created or built.
For example lets say I want to store the content of a database in the volume. At the creation of the volume I would like to create the database schema, but once this schema exists I don’t want to create it again since it could cause some unwanted side effects.
Right now one of the solution I see is to create a flag in the volume once it has been initialized and in later calls check if this flag exists before performing the initialization.
I just wanted to know if docker has a native way of achieving it.
One Solution collect form web for “Initialize docker volume ony once”
Create your own custom image that gets built with database schema created with database’s data directory stored into a docker volume. Later on use that image to create/run containers.