I have a simple docker file
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
ENV LD_LIBRARY_PATH="/app:$LD_LIBRARY_PATH"
When I do a simple docker build --check .
it shows this warning.
Usage of undefined variable '$LD_LIBRARY_PATH'
Dockerfile:2
--------------------
1 | FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
2 | >>> ENV LD_LIBRARY_PATH="/app:$LD_LIBRARY_PATH"
3 |
4 |
--------------------
What is the proper way to augment ENV variables like these without triggering warnings ? This is more of a general question on how do you know which ENV variable is declared or not in the base image and how to augment it without triggering a warning.
2
This is more of a general question on how do you know which
ENV
variable is declared or not in the base image
You can ask for your image to print its environment variables:
docker run --rm mcr.microsoft.com/dotnet/aspnet:6.0 printenv
And since Dockerfile variables do have an interpolation syntax, you can use a default empty value, to cover the case where LD_LIBRARY_PATH
is not defined:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
ENV LD_LIBRARY_PATH="/app:${LD_LIBRARY_PATH:-}"