1

I am trying to access a deb package on my host, for installation in my docker build.

My Dockerfile looks like this:

RUN mkdir /install_files
ADD /opt/jdk-14.0.2_linux-x64_bin.deb /install_files/
RUN dpkg -i /install_files/jdk-14.0.2_linux-x64_bin.deb

And my host has the file:

$ ls /opt
    jdk-14.0.2_linux-x64_bin.deb 
    # other stuff

I run docker build from a shell script, and the result is this:

Step 17/22 : ADD /opt/jdk-14.0.2_linux-x64_bin.deb /install_files/
ADD failed: stat /home/gauthier/.docker-images/tmp/docker-builder811924854/opt/jdk-14.0.2_linux-x64_bin.deb: no such file or directory

I read about ADD here, and I don't see how I'm using it wrong. Somehow, docker looks in a tmp directory instead of the host's /opt/. It might be wrong or not, I don't know.

How do I use the deb package from my host, to build the docker image?

Gauthier
  • 40,309
  • 11
  • 63
  • 97
  • What is the full docker build command that you used to build the image? – betelgeuse Nov 09 '20 at 12:27
  • You can only `COPY` (or `ADD`) files from the directory tree you name in the `docker build` command; even if something looks like an absolute path, it's always interpreted relative to that _build context_ directory. [How to include files outside of Docker's build context?](https://stackoverflow.com/questions/27068596/how-to-include-files-outside-of-dockers-build-context) discusses this more, but the approach there is a little more oriented towards sibling directories than arbitrary locations on the host. I'd `cp` the file into the local directory first. – David Maze Nov 09 '20 at 12:27
  • (Or, depending on what else your image does, build it `FROM openjdk:14` instead of trying to install the JVM separately.) – David Maze Nov 09 '20 at 12:28
  • @DavidMaze thanks for the relative path thing, and the hint at building from an image with openjdk. I did build with openjdk14 (obtained in the container from `apt`), but it was significantly slower than when I had oracle jdk8 (native, not in docker). I am now attempting oracle jdk14, to see if that would be faster. – Gauthier Nov 09 '20 at 12:39

0 Answers0