Last active
February 24, 2023 20:19
-
-
Save triangletodd/905f0dd42bad25ecdd2f8a3a12c5e717 to your computer and use it in GitHub Desktop.
Passing environment variables to docker run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ TEST_1=one | |
$ TEST_2=two | |
$ PATTERN2_1=one | |
$ PATTERN2_2=two | |
$ docker run -d --name test $(for var in $(set | grep -E '^TEST_|^PATTERN2_'); do printf -- '-e "%s" ' $var; done) nginx | |
541a23d4e432b375f71b081593d533de0aeb0b918f74d911bee7c36c95bcc4e3 | |
$ docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
541a23d4e432 nginx "/docker-entrypoint.…" 3 seconds ago Up 2 seconds 80/tcp test | |
$ docker exec test env | |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
HOSTNAME=541a23d4e432 | |
PATTERN2_1=one | |
PATTERN2_2=two | |
TEST_1=one | |
TEST_2=two | |
NGINX_VERSION=1.23.3 | |
NJS_VERSION=0.7.9 | |
PKG_RELEASE=1~bullseye | |
HOME=/root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment