Some values take the form of rather long strings, such as package lists to install and remove.
Please support multiline values for ENV and ARG, similar to backslash multiline syntax for RUN.
Share and learn in the Docker community.
Some values take the form of rather long strings, such as package lists to install and remove.
Please support multiline values for ENV and ARG, similar to backslash multiline syntax for RUN.
It is already supported
FROM ubuntu
ARG TEST1="\
1234567\
1234567\
"
ENV TEST1=$TEST1
ENV TEST2="\
1234567\
1234567\
"
docker build . -t localhost/arg
docker run --rm -it localhost/arg env
Output:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=da6af4596cd2
TERM=xterm
TEST1=12345671234567
TEST2=12345671234567
HOME=/root
But if it wern’t supported or you meant heredoc, we couldn’t do it as community members. Feature requests can be shared on the roadmap
Hmm. Maybe indentation preserving ends up breaking apt install / apt remove commands.
Can you show an error message that made you think multiline variables were not supported?
In my test the final value did not even contain any whitespace, so that should not break anything.
NOTE: I edited my previous post. Just added a backslash right after the opening quotation mark, but the result is the same.
Update: Oh.. If I understand it correctly, you indented the second line and the package name became two separate package names.
Update2:
Just in case you need indentation:
FROM ubuntu
ARG PACKAGES="\
pkg1\
-1234567\
-89;\
pkg2\
-9876543\
-21\
"
RUN echo COMMAND: apt install $(echo "$PACKAGES" | sed "s/ //g" | sed "s/;/ /g")
If it is not enough and you really need a Docker feature, the roadmap is the right place. In my exmple white spaces will be ignored and semicolon will be a space.