在 Gitlab CI 的 Docker 中启动 nginx 时出现错误

问题描述 投票:0回答:1

在 Gitlab CI 中运行部署作业时发生错误(docker:dind executor, gitlab runner 在 docker 中运行)。在本地机器上一切正常。 很好。

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/builds/daniskazan/goboards-backend/nginx/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": create mount destination for /etc/nginx/nginx.conf mount: cannot mkdir in /var/lib/docker/overlay2/cbcfa805f4e22d4b77cee331b5aee81ff2c8bb240fdd266cdce1d4c8bdc9642a/merged/etc/nginx/nginx.conf: 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-compose.yaml

services:
  nginx:
    image: nginx:1.25
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/log:/var/log/nginx
    container_name: nginx-${ENVIRONMENT:-local}
    ports:
      - "80:80"
docker nginx cicd
1个回答
0
投票

你错过了一件事。在挂载之前,挂载的文件应该已经存在于 docker 主机中。否则 docker 会创建一个目录。

所以你需要在安装之前创建

nginx.conf
空文件

© www.soinside.com 2019 - 2024. All rights reserved.