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

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

Closed
akdor1154 opened this issue May 9, 2021 · 10 comments · Fixed by #3548
Closed

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

akdor1154 opened this issue May 9, 2021 · 10 comments · Fixed by #3548

Comments

@akdor1154
Copy link

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)

@ashley-cui ashley-cui self-assigned this May 13, 2021
@fumiyas
Copy link

fumiyas commented Jun 11, 2021

With a newest buildah:

$ buildah --version
buildah version 1.21.0 (image-spec 1.0.1, runtime-spec 1.0.2-dev)
$ buildah bud -f Containerfile .
STEP 1: FROM debian:10
STEP 2: RUN mkdir buildcontext
STEP 3: RUN --mount=type=bind,source=.,target=/buildcontext /buildcontext/setup.sh
error building at STEP "RUN --mount=type=bind,source=.,target=/buildcontext /buildcontext/setup.sh": error resolving mountpoints for container "86d86c2b818bfad56b7a46e61962e0aa213e9b6c873b62c7f8b7f7793cfb081c": invalid filesystem type "bind"

It seems that buildah does NOT support type=bind on RUN --mount=....

@rhatdan
Copy link
Member

rhatdan commented Jun 17, 2021

Interested in opening a PR?

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Aug 16, 2021

@ashley-cui do you have time to work on this one?

@ashley-cui
Copy link
Member

@rhatdan should be able to get to it this sprint.

@mdbooth
Copy link

mdbooth commented Aug 31, 2021

Ditto with type-volume in 1.22.0

Dockerfile contains:

RUN --mount=type=volume,source=modcache,destination=/go/pkg/mod go mod download

buildah errors:

[1/2] STEP 9/17: RUN --mount=type=volume,source=modcache,destination=/go/pkg/mod go mod download
error building at STEP "RUN --mount=type=volume,source=modcache,destination=/go/pkg/mod go mod download": error resolving mountpoints for container "e0e6d226820465b92e613f0df8202d55bbd8467d7954bf2f082eb1fc977a3346": invalid filesystem type "volume"
$ buildah version
Version:         1.22.0
Go Version:      go1.16.6
Image Spec:      1.0.1-dev
Runtime Spec:    1.0.2-dev
CNI Spec:        0.4.0
libcni Version:  v0.8.1
image Version:   5.15.0
Git Commit:
Built:           Thu Aug  5 19:03:31 2021
OS/Arch:         linux/amd64

@ashley-cui
Copy link
Member

We're working on getting each of these features in one by one :)

@mdbooth
Copy link

mdbooth commented Sep 1, 2021

Incidentally, I was originally looking for --mount=type=cache in the unlikely event it's not already on your radar 😀

@flouthoc
Copy link
Collaborator

/assign

@flouthoc
Copy link
Collaborator

@akdor1154 @fumiyas Above PR should close this

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants