Skip to content

Instantly share code, notes, and snippets.

@sergiobuj
Last active February 17, 2024 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergiobuj/b1376d8385c0be2deac729ee64dc6b63 to your computer and use it in GitHub Desktop.
Save sergiobuj/b1376d8385c0be2deac729ee64dc6b63 to your computer and use it in GitHub Desktop.
troubleshoot docker ENV
FROM alpine:latest
ENV no_proxy internal.example.com,internal2.example.com
ENV NO_PROXY internal.example.com,internal2.example.com
RUN apk update && apk upgrade
FROM base_alpine:latest
ENV no_proxy itworks
ENV NO_PROXY itworks
RUN echo ${no_proxy}
RUN echo ${NO_PROXY}
FROM ubuntu:latest
ENV no_proxy internal.example.com,internal2.example.com
ENV NO_PROXY internal.example.com,internal2.example.com
RUN apt update && apt upgrade -y
FROM base_ubuntu:latest
ENV no_proxy itworks
ENV NO_PROXY itworks
RUN echo ${no_proxy}
RUN echo ${NO_PROXY}
#!/bin/zsh
export DOCKER_CLI_HINTS=false
# Build some base images
docker build . -f Dockerfile_ubuntu -t base_ubuntu
docker build . -f Dockerfile_alpine -t base_alpine
# Build the secondary images
docker build . -f Dockerfile_ubuntu_override -t overrider_ubuntu
docker build . -f Dockerfile_alpine_override -t overrider_alpine
# Test the env override
on_ubuntu=$(docker run overrider_ubuntu env | grep -i proxy)
on_alpine=$(docker run overrider_alpine env | grep -i proxy)
echo "on ubuntu the env var is: \n$on_ubuntu"
echo "on alpine the env var is: \n$on_alpine"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment