skip to Main Content

We have various docker-compose files that create a service infrastructure. My question is if it is possible to only create the volumes defined in the compose file without creating the containers?

2

Answers


  1. It might be possible without starting any services.

    command can be provided like this.

    docker-compose up --no-start --no-deps
    

    Or it’s possible to specify individual volume.

    docker-compose up --no-deps -d --volume <volume-name>
    
    Login or Signup to reply.
  2. You can use a docker-compose.override.yml file with invalid entrypoints or different image (use a small template image) for those containers, that way they’ll die immediately.

    docker-compose.override.yml:

    <conatiner-name>:
            image: hello-world
            command: "/hello"
            restart: "no"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search