Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add sh/bash example for SHELL #21141

Open
1 task done
pythoninthegrass opened this issue Oct 16, 2024 · 0 comments
Open
1 task done

docs: Add sh/bash example for SHELL #21141

pythoninthegrass opened this issue Oct 16, 2024 · 0 comments
Labels
area/build Relates to Dockerfiles or docker build command status/triage Needs triage

Comments

@pythoninthegrass
Copy link

Is this a docs issue?

  • My issue is about the documentation content or website

Type of issue

I can't find what I'm looking for

Description

Hadolint points to the online documentation for the SHELL directive. Which is good.

However, all that's given here is a powershell example.

That might be useful on windows or dotnet related dockerfiles, but not so handy for linux ones.

Location

https://docs.docker.com/reference/dockerfile/

Suggestion

Maybe a more detailed example based on the moby repo?:

SHELL ["/bin/bash", "-c"]
RUN echo I am now using bash!

This is me taking a stab at setting shell flags and options

# syntax=docker/dockerfile:1.7.0

FROM ubuntu:latest

SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]

RUN <<EOF
#!/bin/bash
# set -euxo pipefail
echo "Shell: ${SHELL}" > /tmp/test.txt
echo "Shell options after explicit set: ${-}" >> /tmp/test.txt
echo "Detailed shell options:" >> /tmp/test.txt
set -o >> /tmp/test.txt
EOF

CMD ["cat", "/tmp/test.txt"]

which doesn't work as expected without uncommenting the inline set opts.

Shell: /bin/bash
Shell options after explicit set: hB
Detailed shell options:
allexport       off
braceexpand     on
emacs           off
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      off
history         off
ignoreeof       off
interactive-comments    on
keyword         off
monitor         off
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off
@pythoninthegrass pythoninthegrass added the status/triage Needs triage label Oct 16, 2024
@thaJeztah thaJeztah added the area/build Relates to Dockerfiles or docker build command label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Relates to Dockerfiles or docker build command status/triage Needs triage
Projects
None yet
Development

No branches or pull requests

2 participants