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

Docker documentation erroneously claims Here-Documents being a Docker feature – they are a shell feature instead #19926

Open
1 task done
SetTrend opened this issue Apr 30, 2024 · 3 comments
Labels
status/need-more-info Need more information about the issue/PR

Comments

@SetTrend
Copy link

SetTrend commented Apr 30, 2024

Is this a docs issue?

  • My issue is about the documentation content or website

Type of issue

Information is incorrect

Description

The Docker documentation claims that Here-Documents are a Docker feature that may be used with every shell.

However, Here-Documents do not work with Windows cmd or PowerShell.

Location

https://docs.docker.com/reference/dockerfile/#here-documents

Suggestion

It should be explicitly mentioned in the documentation that Here-Documents are a shell feature that is only available to shells supporting this feature and it's just coincidentally available to the Dockerfile RUN instruction due to the shell supporting this feature.

@SetTrend SetTrend added the status/triage Needs triage label Apr 30, 2024
@dvdksn
Copy link
Contributor

dvdksn commented Apr 30, 2024

This section refers to heredocs in Dockerfiles, and has nothing to do with shells. It refers to BuildKit's ability to interpret multi-line RUN and COPY instructions by using heredoc delimiters for those instructions, as shown in the examples.

Are you observing some kind of issue with heredocs in Dockerfiles?

@dvdksn dvdksn added status/need-more-info Need more information about the issue/PR and removed status/triage Needs triage labels Apr 30, 2024
@SetTrend
Copy link
Author

SetTrend commented Apr 30, 2024

Yet, apparently, the Here-Document is interpreted by the shell, not by the Dockerfile:

When I'm using this Dockerfile:

# escape=`
FROM mcr.microsoft.com/windows/servercore:20H2
RUN <<EOT
  ECHO.
EOT

… I'm getting this build output:

Sending build context to Docker daemon ...
Step 1/2 : FROM mcr.microsoft.com/windows/servercore:20H2
 ---> d7c03b5bcc73
Step 2/2 : RUN <<EOT
 ---> Running in 1e07112fa6d9
<< was unexpected at this time.
The command 'cmd /S /C <<EOT' returned a non-zero code: 1

@dvdksn
Copy link
Contributor

dvdksn commented May 1, 2024

@tonistiigi is this working as intended? I would've thought that the heredocs for RUN are shell-agnostic, but looks like they aren't. Do Windows shells have an alternative syntax, e.g. PowerShell here-strings? https://devblogs.microsoft.com/scripting/powertip-use-here-strings-with-powershell/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/need-more-info Need more information about the issue/PR
Projects
None yet
Development

No branches or pull requests

2 participants