amorfis
amorfis

Reputation: 15770

Access data generated in one docker container in another one

I need to run a few docker containers using docker-compose.yml. Each docker container has an entrypoint, where it creates the config file for the process. I can't change the process itself (I have only the executable file), only it's configuration.

The first container is a "master". It generates keys, and the others need to have this keys in their configuration.

How can I pass the generated keys from the "master" to the other containers? I could use shared volume, but maybe there is some better way?

Upvotes: 0

Views: 58

Answers (1)

larsks
larsks

Reputation: 311645

A shared volume is really the best way and the most common solution to this problem. Define the volume in your docker-compose.yml and then mount it at a common location in each container. Something like:

version: "3"

services:
  foo:
    image: service/foo
    volumes:
      - "config:/config"

  bar:
    image: service/bar
    volumes:
      - "config:/config"

volumes:
  config:

Upvotes: 2

Related Questions