Dockerfile - dynamic variable ENV definition

I want to update the PATH environment variable with a dynamic value. This is what I have tried so far in my Docker file:

...
ENV PATH '$(dirname $(find /opt -name "ruby" | grep -i bin)):$PATH'
...

But the export shows that the command was not interpreted:

root@97287b22c251:/# export
declare -x PATH="\$(dirname \$(find /opt -name \"ruby\" | grep -i bin)):\$PATH"

I do not want to set the value hard. Can this be achieved?

thanks

+6
source share
1 answer

Not sure if something like this is what you are looking for ... changing a bit of what you already have. My main question is: what are you trying to achieve with this part ?: '$(dirname $(find/opt -name "ruby" | grep -i bin)):$PATH'Part of the problem may be the use of single and double quotes leading to extensions.

FROM alpine:3.4
RUN PATH_TO_ADD=$(dirname $(find /opt -name "ruby" | grep -i bin)) || echo Error locating files
ENV PATH "$PATH:$PATH_TO_ADD"
0
source

Source: https://habr.com/ru/post/1624825/


All Articles