docker compose build failed
Description
Steps to reproduce the issue:
- create a
Dockerfilecontent
FROM alpine
RUN set -x && apk add -u bash
- create a
compose.ymlcontent
services:
test:
image: test
build: .
- run
docker compose build
Describe the results you received:
[+] Building 0.2s (5/5) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 31B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 0.0s
=> CACHED [1/2] FROM docker.io/library/alpine 0.0s
=> ERROR [2/2] RUN set -x && apk add -u bash 0.1s
------
> [2/2] RUN set -x && apk add -u bash:
#0 0.109 container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:57: preparing rootfs caused: permission denied
------
failed to solve: executor failed running [/bin/sh -c set -x && apk add -u bash]: exit code: 1
Describe the results you expected: build image successful
Additional information you deem important (e.g. issue happens only occasionally):
No problem if use the docker build -t test . command to create the image
Output of docker compose version:
Docker Compose version v2.4.1
Output of docker info:
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.1-docker)
compose: Docker Compose (Docker Inc., v2.4.1)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 9
Running: 7
Paused: 0
Stopped: 2
Images: 64
Server Version: 20.10.14
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
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 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc version: v1.0.3-0-gf46b6ba
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: default
userns
cgroupns
Kernel Version: 5.15.0-25-generic
Operating System: Ubuntu Jammy Jellyfish (development branch)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 971.2MiB
Name: somehost
ID: 7PVS:ED7Y:FMRB:2QY5:NHG7:VTX6:WH3P:AMJV:WATN:PY2F:APDK:MNN2
Docker Root Dir: /var/lib/docker/165536.165536
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details:
@SquallATF
Since you do not specify the version of the alpine image, I'm having hard time to reproduce the issue.
Does the issue also occurred when using a specific version ?
eg:
FROM alpine:3.15.4
On my end :
➜ cat Dockerfile
FROM alpine:3.15.4
RUN set -x && apk add -u bash
➜ cat compose.yml
services:
test:
image: test
build: .
➜ docker compose version
Docker Compose version v2.4.1
➜ docker compose build --no-cache
[+] Building 2.1s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 86B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:3.15.4 1.1s
=> CACHED [1/2] FROM docker.io/library/alpine:3.15.4@sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454 0.0s
=> [2/2] RUN set -x && apk add -u bash 0.9s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:eab637bb5e035636bcb5c3cf0e5f2fddc3d6b3d04bdc4b2ca1e20a0673bcd065 0.0s
=> => naming to docker.io/library/test 0.0s
@SquallATF
Since you do not specify the version of the
alpineimage, I'm having hard time to reproduce the issue.Does the issue also occurred when using a specific version ?
eg:
FROM alpine:3.15.4On my end :
➜ cat Dockerfile FROM alpine:3.15.4 RUN set -x && apk add -u bash ➜ cat compose.yml services: test: image: test build: . ➜ docker compose version Docker Compose version v2.4.1 ➜ docker compose build --no-cache [+] Building 2.1s (6/6) FINISHED => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 86B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/alpine:3.15.4 1.1s => CACHED [1/2] FROM docker.io/library/alpine:3.15.4@sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454 0.0s => [2/2] RUN set -x && apk add -u bash 0.9s => exporting to image 0.0s => => exporting layers 0.0s => => writing image sha256:eab637bb5e035636bcb5c3cf0e5f2fddc3d6b3d04bdc4b2ca1e20a0673bcd065 0.0s => => naming to docker.io/library/test 0.0s
It seems to be caused by setting usersns-remap, I have two vps with usersns-remap set to default, all of them build image failed. Another vps without usersns-remap configured has no problem. And docker-compose v1 does not have this issue.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it had not recent activity during the stale period.