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.

  • Starting services at container startup
  • A different VM with name panamax-vm has been created already
  • AWS opswork docker: Missing Cookbooks:No such cookbook: docker
  • Cannot start container on docker compose
  • Play 2.5.x in Docker container not updating through shared folder
  • How can I debug my docker with PHPStorm
  • 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.

  • Cron job can't connect to Docker daemon
  • How to use docker to connect with jupiter notebooks
  • Cloudbees jenkins plugin fails to start containers
  • Build Docker image for ARM architecture on Intel machine (Mac)
  • How do I link and scale multiple docker containers?
  • Why am i forced to run docker with sudo on OS X?
  • 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.