我在 docker-compose.yml 中的 Nginx:
...
nginx:
image: nginx:1.19.2-alpine
restart: always
hostname: nginx
ports:
- "9000:9000"
- "9001:9001"
depends_on:
- minio
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
container_name: nginx
...
我docker compose up -d在終端中使用,它作業正常。
但是,當我docker compose up -d在 Jenkins 容器中使用時,它無法創建 Nginx 容器并出現以下錯誤:
ERROR: for nginx Cannot start service nginx: failed to create shim: OCI runtime create failed:
container_linux.go:380: starting container process caused: process_linux.go:545:
container init caused: rootfs_linux.go:75: mounting
"/var/jenkins_home/workspace/workspace/nginx.conf" to rootfs at "/etc/nginx/nginx.conf" caused:
mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file
(or vice-versa)? Check if the specified host path exists and is the expected type
該錯誤是否意味著 Docker 想要將檔案掛載到 Jenkins 的卷中,所以沒有nginx.conf掛載?
如何將我的掛載nginx.conf到我的 Nginx 容器?
提前致謝。
uj5u.com熱心網友回復:
看起來您是docker-compose up從某個位置執行的,例如您的相對路徑 ./nginx.conf 不正確。
當 docker-compose 找不到掛載系結卷的源時,此錯誤很典型。
確保您在正確的 docker-compose 背景關系中或嘗試使用絕對路徑而不是 ./nginx.conf
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/464486.html
