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.

  • Docker - Downloaded war not found
  • Enable logging in docker mysql container
  • Docker push to AWS ECR private repo failing with malformed JSON
  • Can't interact with java process when attaching
  • Can't Ping a Pod after unbuntu cluster setup
  • Execution commands between two dockers containers
  • 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.

  • How to access Docker container from another machine on lan
  • How to configure an application in openshift via a REST endpoint?
  • Docker with php built-in server
  • DNS not working with Kubernetes PetSet
  • StopIteration() after a few minutes of workers job
  • Docker: group of a shared volume changes depending on host user
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.