我被 Dockerfile 困住了:
[2/2] STEP 31/42: COPY /opt/SIMULATeQCD/src /simulateqcd/src
Error: error building at STEP "COPY /opt/SIMULATeQCD/src /simulateqcd/src": checking on sources under "/opt/SIMULATeQCD/podman-build": copier: stat: "/opt/SIMULATeQCD/src": no such file or directory
但是,它确实存在,所以我对 podman
正在寻找什么感到困惑:
[grant@simulateqcd podman-build]$ ls -al /opt/SIMULATeQCD/src
total 144
drwxr-xr-x. 12 grant grant 4096 Apr 14 16:23 .
drwxr-xr-x. 3 root root 25 Apr 14 16:20 ..
-rw-r--r--. 1 grant grant 52854 Apr 14 16:09 CMakeLists.txt
-rwxr-xr-x. 1 grant grant 126 Apr 14 16:09 cmake.sh
我花了 45 分钟的大部分时间来处理上下文、检查权限、关闭 SELinux,并且不知道还需要检查什么。我已经在我能想到的所有地方都给了它绝对路径,但它仍然说该路径不存在。
任何地方的一切都由 1000:1000 拥有。上下文目录为/opt/SIMULATeQCD,Dockerfile 位于/opt/SIMULATeQCD/podman-build 中。我像这样运行 Dockerfile:
podman build \
--tag simulateqcd/simulateqcd:latest \
--label name=simulateqcd \
--build-arg CORES=${CORES} \
--build-arg RHEL_VERSION=${RHEL_VERSION} \
--build-arg CUDA_VERSION=${CUDA_VERSION} \
--build-arg USERNAME=${USERNAME} \
--build-arg GROUPNAME=${GROUPNAME} \
--build-arg USER_ID=${USER_ID} \
--build-arg GROUP_ID=${GROUP_ID} \
--build-arg DIRECTORY=$topdir \
-f $scriptdir/Dockerfile
/opt/SIMULATeQCD
也许我还缺少其他东西吗?
更新
Dockerfile 是 here
COPY ./src /simulateqcd/src
COPY ./CMakeLists.txt /simulateqcd/CMakeLists.txt
COPY ./parameter /simulateqcd/parameter
COPY ./scripts /simulateqcd/scripts
COPY ./test_conf /simulateqcd/test_conf
脚本从 this line 运行
podman build \
--tag simulateqcd/simulateqcd:latest \
--label name=simulateqcd \
--build-arg CORES=${CORES} \
--build-arg RHEL_VERSION=${RHEL_VERSION} \
--build-arg CUDA_VERSION=${CUDA_VERSION} \
--build-arg USERNAME=${USERNAME} \
--build-arg GROUPNAME=${GROUPNAME} \
--build-arg USER_ID=${USER_ID} \
--build-arg GROUP_ID=${GROUP_ID} \
--build-arg ARCHITECTURE=${ARCHITECTURE} \
--build-arg USE_GPU_AWARE_MPI=${USE_GPU_AWARE_MPI} \
--build-arg USE_GPU_P2P=${USE_GPU_P2P} \
--build-arg TARGET=${TARGET} \
-f $scriptdir/Dockerfile
$topdir
其中 $topdir = /opt/SIMULATeQCD
和 $scriptdir=/opt/SIMULATeQCD/podman-build
。 src
位于 /opt/SIMUALTeQCD/src
运行./simulateqcd build
可以得到:
Error: error building at STEP "COPY ./src /simulateqcd/src": checking on sources under "/opt/SIMULATeQCD/podman-build": copier: stat: "/src": no such file or directory
./simulate_qcd.sh: line 285: /opt/SIMULATeQCD: Is a directory
最佳答案
问题的两个相关方面是 Dockerfile
路径,可以通过 -f
选项和构建上下文提供,它是构建命令。
在 podman build
命令中设置上下文时,Dockerfile
内的所有后续 COPY
指令都相对于上下文路径。
假设您有以下目录结构:
.
├── opt
│ └── SIMULATeQCD
│ └── src
│ ├── CMakeLists.txt
│ └── cmake.sh
└── scripts
└── Dockerfile
如果您像这样运行构建命令:
podman build -f scripts/Dockerfile -t alpine-context-so-img opt/SIMULATeQCD/src/
然后,Dockerfile
应该COPY
文件,就好像主机上的当前工作目录是 /opt/SIMULATeQCD/src
:
FROM alpine:3.14
WORKDIR /target-path-in-container
# Next line is valid and also copies the two files
# COPY . .
# But for better exemplification, I am copying each
# file verbosely:
COPY ./cmake.sh .
COPY ./CMakeLists.txt .
ENTRYPOINT [ "ls", "/target-path-in-container"]
现在,如果您运行容器,则应该在容器中找到这两个文件:
$ podman run alpine-context-so-img
CMakeLists.txt
cmake.sh
关于dockerfile - Podman 在复制时提示目录不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76019045/