How to prepend something to CLI in docker container?
The error you get certainly comes from the fact you use single quotes '
instead of double quotes "
in the ENTRYPOINT
exec form.
In addition, I don't think the "$@"
phrasing you mention will work (because "$@"
needs some shell to evaluate it, while in the exec form there is no /bin/sh -c …
implied). But the exec form of ENTRYPOINT
is definitely the way to go.
So I'd suggest you write something like this:
FROM centeredge/nugetARG VERSION="14.1.0.0-prerelease"RUN nuget install Microsoft.Build.Mono.Debug -Version $VERSION -Source "https://www.myget.org/F/dotnet-buildtools/"ENV PATH="/Microsoft.Build.Mono.Debug.$VERSION/lib/:${PATH}"COPY entrypoint.sh /usr/src/RUN chmod a+x /usr/src/entrypoint.shENTRYPOINT ["/usr/src/entrypoint.sh"]
with entrypoint.sh
containing:
#!/bin/bashexec /usr/bin/mono "/Microsoft.Build.Mono.Debug.$VERSION/lib/$1" "$@"
(Note: I didn't test this example code for now so please comment if you find some typo)
Final working solution based on @ErikMD's answer:
FROM centeredge/nugetARG VERSION="14.1.0.0-prerelease"RUN nuget install Microsoft.Build.Mono.Debug -Version $VERSION -Source "https://www.myget.org/F/dotnet-buildtools/"ENV PATH="/Microsoft.Build.Mono.Debug.$VERSION/lib/:/Microsoft.Build.Mono.Debug.$VERSION/lib/tools/:${PATH}"RUN echo '#!/bin/bash' > /usr/src/entrypoint.sh && echo 'exec /usr/bin/mono "$(which "$1")" "$@"' >> /usr/src/entrypoint.sh && chmod a+x /usr/src/entrypoint.shENTRYPOINT ["/usr/src/entrypoint.sh"]
output
docker run -it mstools MSBuild.exe -versionMicrosoft (R) Build Engine version 14.1.0.0Copyright (C) Microsoft Corporation. All rights reserved.14.1.0.0