Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Read ¶
Read retrieves the value of the environment variable named by the key. As an alternative to passing sensitive information via environment variables, _FILE may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. In particular, this can be used to load passwords from Docker secrets stored in /run/secrets/<secret_name> files.
https://docs.docker.com/engine/swarm/secrets/ https://docs.docker.com/compose/compose-file/compose-versioning/#version-31
docker-compose.yml ------------------ version: "3.1"
secrets:
mypassword: external: true
services:
app: image: your-app-in-docker-image environment: - PASSWORD_FILE=/run/secrets/mypassword - LOGIN=mylogin
EXAMPLE:
passwd, _ := env.Read("PASSWORD") // reading from PASSWORD_FILE login, _ := end.Read("LOGIN") // reading from LOGIN.