Instead of ARG or ENV, you should use secret mounts, https://docs.docker.com/build/building/secrets/#secret-mounts Get warnings in builds SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data