DockerCLI/cli/command
Sebastiaan van Stijn 847aef321e
build: fix AddDockerfileToBuildContext not de-referencing tar header template
Commit 73aef6edfe
modified archive.ReplaceFileTarWrapper to set the Name field in the tar header,
if the field was not set.

That change exposed an issue in how a Dockerfile from stdin was sent to the daemon.
When attempting to build using a build-context, and a Dockerfile from stdin, the
following happened:

```bash
mkdir build-stdin && cd build-stdin && echo hello > hello.txt

DOCKER_BUILDKIT=0 docker build --no-cache -t foo -f- . <<'EOF'
FROM alpine
COPY . .
EOF

Sending build context to Docker daemon  2.607kB
Error response from daemon: dockerfile parse error line 1: unknown instruction: .DOCKERIGNORE
```

Removing the `-t foo`, oddly lead to a different failure:

```bash
DOCKER_BUILDKIT=0 docker build --no-cache -f- . <<'EOF'
FROM alpine
COPY . .
EOF

Sending build context to Docker daemon  2.581kB
Error response from daemon: Cannot locate specified Dockerfile: .dockerfile.701d0d71fb1497d6a7ce
```

From the above, it looks like the tar headers got mangled, causing (in the first
case) the daemon to use the build-context tar as a plain-text file, and therefore
parsing it as Dockerfile, and in the second case, causing it to not being able to
find the Dockerfile in the context.

I noticed that both TarModifierFuncs were using the same `hdrTmpl` struct, which
looks to caused them to step on each other's toes. Changing them to each initialize
their own struct made the issue go away.

After this change:

```bash
DOCKER_BUILDKIT=0 docker build --no-cache -t foo -f- . <<'EOF'
FROM alpine
COPY . .
EOF
Sending build context to Docker daemon  2.607kB
Step 1/2 : FROM alpine
 ---> d4ff818577bc
Step 2/2 : COPY . .
 ---> 556f745e6938
Successfully built 556f745e6938
Successfully tagged foo:latest

DOCKER_BUILDKIT=0 docker build --no-cache -f- . <<'EOF'
FROM alpine
COPY . .
EOF

Sending build context to Docker daemon  2.607kB
Step 1/2 : FROM alpine
 ---> d4ff818577bc
Step 2/2 : COPY . .
 ---> aaaee43bec5e
Successfully built aaaee43bec5e
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-10 23:19:14 +02:00
..
builder Fix builder prune -a/--all flag description 2020-02-18 14:30:28 +01:00
checkpoint Replace deprecated Cobra command.SetOutput() with command.SetOut() 2020-05-07 14:25:59 +02:00
commands Remove "docker engine" subcommands 2019-12-12 17:51:25 +01:00
config formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
container replace docker/pkg/signal with github.com/moby/sys/signal 2021-08-09 19:15:46 +02:00
context Deprecate Kubernetes context support 2021-07-01 18:39:00 +02:00
formatter formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
idresolver bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
image build: fix AddDockerfileToBuildContext not de-referencing tar header template 2021-08-10 23:19:14 +02:00
inspect bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
manifest Subcommand `docker manifest rm` 2020-09-15 16:26:47 -04:00
network formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
node formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
plugin formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
registry Fix panic when failing to get DefaultAuthConfig 2021-01-07 22:11:29 +01:00
secret formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
service UX: don't reverse progress-bars when rolling back 2021-06-22 10:28:46 +02:00
stack Deprecate Kubernetes stack support 2021-07-01 18:39:00 +02:00
swarm Use designated test domains (RFC2606) in tests 2021-04-30 10:03:45 +02:00
system info: print errors to stderr 2021-07-13 11:43:32 +02:00
task formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
testdata Dynamically register kubernetes context store endpoint type. 2019-05-20 13:28:11 +01:00
trust formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
volume formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
cli.go context: deprecate support for encrypted TLS private keys 2021-07-28 14:42:45 +02:00
cli_options.go update docker, replace github.com/docker/pkg/term, github.com/docker/pkg/mount 2020-04-22 17:16:13 +02:00
cli_options_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
cli_test.go cli/command: don't use client.CustomHTTPHeaders(), and simplify asserts 2021-07-29 10:26:10 +02:00
context.go Don't loose additional metadata fields 2020-06-10 15:07:23 +02:00
context_test.go Don't loose additional metadata fields 2020-06-10 15:07:23 +02:00
defaultcontextstore.go Push check for kubernetes requirement down into the endpoint 2019-05-20 13:28:11 +01:00
defaultcontextstore_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
events_utils.go updated vendoring 2017-09-01 19:41:06 -04:00
orchestrator.go Fast Context Switch: commands 2019-01-10 22:25:43 +01:00
orchestrator_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
registry.go Fix panic when failing to get DefaultAuthConfig 2021-01-07 22:11:29 +01:00
registry_test.go Use designated test domains (RFC2606) in tests 2021-04-30 10:03:45 +02:00
streams.go Extract streams helpers from command package to their own package to remove a cyclic dependency from command to internal/containerizedengine 2019-01-28 14:36:00 +01:00
trust.go Refactor content_trust cli/flags handling 2018-03-08 15:00:43 -05:00
utils.go build: remove PersistentPreRunE hack for experimental --platform 2020-11-16 14:58:11 +01:00
utils_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00