Skip to content

Instantly share code, notes, and snippets.

@hudon
hudon / dockerize-env
Last active April 1, 2023 03:30
Workaround so you can use `docker run --env-file .env` and read variables with newline escape sequences in them
#!/bin/bash
# Docker can't pass newlines to containers if there are \n in variables in
# --env-file files. This tool creates a $1.exported file with newlines that
# can be sourced before running your container and a $1.vars for you to pass
# to --env-files so docker passes those variables to the container.
# Usage:
# dockerize-env .env
# This creates: .env.vars and .env.exported