Skip to content

RUN --mount=type=bind doesn't seem to work with relative source paths #3217

@akdor1154

Description

@akdor1154

I'm trying to run a script inside my container during build, without COPYing it.
Docker w/BuildKit is OK with this, but Buildah doesn't seem to like it.

Setup

Dockerfile
setup.sh
#Dockerfile
FROM debian:10

RUN mkdir buildcontext
RUN --mount=type=bind,source=.,target=/buildcontext /buildcontext/setup.sh
#setup.sh
echo hi!

Test

# docker is ok
env DOCKER_BUILDKIT=1 docker build -t test --no-cache --progress plain .
Output
#1 [internal] load build definition from Dockerfile
#1 sha256:bbfc041ced8e7ad3f93c7959439642058755819fda5a27b71c69d70ce9f3aa3c
#1 transferring dockerfile: 37B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 sha256:c11a926a0f68328dfd07b46271743e06e0585e997349009bac5436ba2605736c
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/debian:10
#3 sha256:ddb83d0bde9bcb14777289b1ac16d70d4d9ca3f82a764e7914f87e2e1fd702d1
#3 DONE 0.0s

#4 [1/3] FROM docker.io/library/debian:10
#4 sha256:80c01a5c5fd9f219c4fcc67169879cfd950ce672c8983a4b51eafa65a2907a36
#4 CACHED

#6 [internal] load build context
#6 sha256:a133a8149b38368be0bf659c22b42dcdba408161e18ada0b3f320f3dbd44e934
#6 transferring context: 59B done
#6 DONE 0.0s

#5 [2/3] RUN mkdir buildcontext
#5 sha256:cc1eba7768d6df39d1d00f3e1b66e337ca43fbe5dd52da4f41e927dad18b2ca1
#5 DONE 0.2s

#7 [3/3] RUN --mount=type=bind,source=.,target=/buildcontext /buildcontext/setup.sh
#7 sha256:99af5c3879fbaa722e780a1726e4b4b99a1b852994c0c6bb75d6e7ff066e85d0
#7 0.267 hi!
#7 DONE 0.3s

#8 exporting to image
#8 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#8 exporting layers 0.0s done
#8 writing image sha256:043675d6ba158e1e2bca787228f4b1d49caeee41dfede09d56d0490f6e80318e done
#8 naming to docker.io/library/test done
#8 DONE 0.0s
#buildah is not ok
buildah bud -t test .
Output:
STEP 1: FROM debian:10
STEP 2: RUN mkdir buildcontext
STEP 3: RUN --mount=type=bind,source=.,target=/buildcontext /buildcontext/setup.sh
/bin/sh: 1: /buildcontext/setup.sh: not found
error building at STEP "RUN --mount=type=bind,source=.,target=/buildcontext /buildcontext/setup.sh": error while running runtime: exit status 127
ERRO exit status 127    

Details

buildah version 1.19.6 (image-spec 1.0.1, runtime-spec 1.0.2-dev)
Ubuntu distro package on 21.04 x86_64.
Also tested with buildah from kupic repo as per podman docs - same result.
buildah version 1.20.1 (image-spec 1.0.1-dev, runtime-spec 1.0.2-dev)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions