jum / env2dockerenv

Convert a .env file to what is usable for docker --env-file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

env2dockerenv

A small utility to convert .env files used by the shell to environment files accepted by the docker --env-file option.

Each line in the normal .env file looks like:

export VAR="value"

A docker env file has just:

VAR=value

To convert, we have to remove any quotes and remove the export statement. As an additional complication, there exists a convention of using:

unset VAR

This will unset a previous variable setting, effectively commenting out the value. This utility will prepend the letter 'X' to the environment variable.

Example usage:

env2dockerenv -infile .env -outfile .dockerenv

Use the -outfile - to preview the output on stdout.

About

Convert a .env file to what is usable for docker --env-file.


Languages

Language:Go 100.0%