Sample Header Ad - 728x90

COPY/ADD from host absolute path in podman/dockerfile

0 votes
0 answers
50 views
Dockerfile documentation states that the `` argument of COPY and ADD are relative to the context (location of Dockerfile). If I have third party dependencies located in /usr/local or /opt/ it seems that I am forced to use relative paths in my dockerfile unless I want to copy and paste those third party libraries multiple times for each container project that utilizes them. For this reason, I have started to install or unpackage all third-party software to live one level above where I store my all my various project's application code (i.e. instead of /usr/local) I'm wondering if anyone has a different solution for building container images that doesn't involve copying and pasting, hard coding relative paths, or installing libraries in non-standard locations. **Edit** Using relative paths is entirely not allowed it seems. If your third-party dependencies live above your dockerfile, i.e. COPY ../third-party/some-lib/ /opt/ you get the error: possible escaping context directory error... ... no such file or directory So, I really have to copy my third party libraries however many times I want to use them in separate projects.
Asked by rocksNwaves (121 rep)
Jun 26, 2025, 04:15 PM
Last activity: Jun 26, 2025, 04:29 PM