Injecting Data into Docker Container

Problem Definitions

So, You built an app. It runs great on CLI. It’s configurable in either way:

  • config file,
  • environment-variable,
  • command flag.

Caveats? Configuration might contains sensitive data: app-secret-id, database-path, database-password, etc.

Note: Contents below requires basic understanding on `docker`. Please read before proceed.

Now, you want to dockerize it. Things just went south. Here’s why:

  • Dockerfile. A set of instructions. Usually ends with an application execution. If you ever consider to execute along with your configuration data, you’re in deep sh*t. The reason is obvious, data that you `hardcoded` will be made available for everyone who obtains your image (output of Dockerfile).
CMD ./app param1=value1 param2=value2 
  • docker-compose.yml. A set of instructions. In addition, a set of collaborative applications. Unlike Dockerfile, you could start/run applications in containers, with command: build. You get to pass in environment variables too, interpolated one.

Coming up, solutions.<

Like what you read? Give roylee0704 a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.