Some Dockerfile fails during build. Result depends of base image used and if I use WORKDIR instruction.
Currently, the same example with node:18-alpine
failed but node:19-alpine
works.
I have read documentation but I don't understand why WORKDIR should have an impact.
env DOCKER_BUILDKIT=0 docker build -f - . <<EOF
FROM node:18-alpine as base
WORKDIR /app
FROM base
RUN ls
EOF
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
environment-variable.
Sending build context to Docker daemon 2.607kB
Step 1/4 : FROM node:18-alpine as base
---> 708a2a137388
Step 2/4 : WORKDIR /app
---> Running in d7f876346e5f
Removing intermediate container d7f876346e5f
---> d6a9aa986205
Step 3/4 : FROM base
---> d6a9aa986205
Step 4/4 : RUN ls
---> Running in c1012a376e5b
Removing intermediate container c1012a376e5b
---> 75ef50e1c86a
Successfully built 75ef50e1c86a
node:18-alpine
env DOCKER_BUILDKIT=1 docker build -f - . <<EOF
FROM node:18-alpine as base
WORKDIR /app
FROM base
RUN ls
EOF
[+] Building 0.4s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 163B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:18-alpine 0.0s
=> [base 1/2] FROM docker.io/library/node:18-alpine 0.0s
=> CACHED [base 2/2] WORKDIR /app 0.0s
=> ERROR [stage-1 1/1] RUN ls 0.3s
------
> [stage-1 1/1] RUN ls:
#0 0.291 runc run failed: unable to start container process: exec: "/bin/sh": stat /bin/sh: no such file or directory
------
Dockerfile:5
--------------------
3 |
4 | FROM base
5 | >>> RUN ls
6 |
--------------------
ERROR: failed to solve: process "/bin/sh -c ls" did not complete successfully: exit code: 1
node:19-alpine
env DOCKER_BUILDKIT=1 docker build -f - . <<EOF
FROM node:19-alpine as base
WORKDIR /app
FROM base
RUN ls
EOF
[+] Building 0.5s (7/7) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 163B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:19-alpine 0.4s
=> [base 1/2] FROM docker.io/library/node:19-alpine@sha256:72b0f918ad76b5ef68c6243869fab5800d7393c1dcccf54ef00958c2abc8164a 0.0s
=> CACHED [base 2/2] WORKDIR /app 0.0s
=> CACHED [stage-1 1/1] RUN ls 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:17ef5f16162747d5069897a2b03ac513179bf77b325d4df5e34bf26b98537304
env DOCKER_BUILDKIT=1 docker build -f - . <<EOF
FROM node:18-alpine as base
FROM base
RUN ls
EOF
[+] Building 1.2s (6/6) FINISHED
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 150B 0.0s
=> [internal] load metadata for docker.io/library/node:18-alpine 0.0s
=> CACHED [base 1/1] FROM docker.io/library/node:18-alpine 0.0s
=> [stage-1 1/1] RUN ls 0.3s
=> exporting to image 0.8s
=> => exporting layers 0.8s
=> => writing image sha256:b6c3fe8530b7e47d4f99c19595d357ae194a0615fe821594b62050436c265647
No response
Client: Docker Engine - Community
Version: 23.0.0
API version: 1.42
Go version: go1.19.5
Git commit: e92dd87
Built: Wed Feb 1 17:47:38 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 23.0.0
API version: 1.42 (minimum version 1.12)
Go version: go1.19.5
Git commit: d7573ab
Built: Wed Feb 1 17:44:45 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.16
GitCommit: 31aa4358a36870b21a992d3ad2bef29e1d693bec
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.10.2
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.15.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
scan: Docker Scan (Docker Inc.)
Version: v0.23.0
Path: /usr/libexec/docker/cli-plugins/docker-scan
Server:
Containers: 32
Running: 1
Paused: 0
Stopped: 31
Images: 413
Server Version: 23.0.0
Storage Driver: btrfs
Btrfs:
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 31aa4358a36870b21a992d3ad2bef29e1d693bec
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.1.9-200.fc37.x86_64
Operating System: Fedora Linux 37 (Workstation Edition)
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 11.51GiB
Name: baptistedonaux
ID: I7I4:HV4T:R4IQ:G3V4:FR3E:GMBT:WADY:PSMW:QNTM:23RI:XODQ:BGL2
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
No response