0

During dockerbuild, I'd like to install a (rather big) RPM from build context/host without copying it first into the image in order to keep my image small. Ideally, there would be a way to read a file directly from build context.

What are my options (beside using a HTTP server on the host)? What are the best practices for this use-case?

2
  • Do you just want a file from the RPM? Commented Feb 25, 2022 at 9:29
  • @mikequentel Nope, I'd like to install the RPM.
    – MRalwasser
    Commented Feb 28, 2022 at 12:33

1 Answer 1

3
+100

Using buildkit, you can mount from the build context with type=bind to access files without including them in your resulting image.

# syntax=docker/dockerfile:1.3
FROM base
RUN --mount=type=bind,source=./rpms/,target=/rpms/ \
    yum install /rpms/package.rpm

See the buildkit docs for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.