【发布时间】:2021-02-24 07:30:31
【问题描述】:
我们有一个使用 docker-compose 进行设置的项目,所以我们想使用相同的东西进行测试(我们已经准备好并在本地运行),但是我遇到了 gitlab 的 ci 的 2 个问题
ERROR: for store_k4g_nginx Cannot start service nginx: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: rootfs_linux.go:59: mounting "/builds/project/whatever/docker/nginx/nginx.conf" to rootfs at "/var/lib/docker/overlay2/dfff5e2d38c01c8726cbd6fb46a44456521025d6cee3c596a6e56f7992938ce8/merged/etc/nginx/nginx.conf" caused: 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
我们正在使用我们自己的运行器,配置如下
[[runners]]
name = "******"
url = "https://gitlab.com/"
token = "*****"
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "docker:stable"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0
ci 脚本看起来像这样
test:
image: docker/compose:latest
stage: test
variables:
APP_ENV: test
before_script:
- apk add bash ncurses
script:
- bash ./scripts/test.sh --no-interaction --compose
Nginx dockerfile
FROM nginx:alpine
WORKDIR /var/www
RUN nginx -t;
CMD nginx
EXPOSE 80
以及 docker-compose 的一部分
nginx:
container_name: app_nginx
build:
context: ./nginx
depends_on:
- php-fpm
volumes:
- ../:/var/www
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/sites:/etc/nginx/sites-available
- ./nginx/conf.d:/etc/nginx/conf.d
- ./logs/nginx:/var/log/nginx
ports:
- "${NGINX_PORT}:80"
test.sh 脚本使用 docker-compose 启动项目,但由于顶部列出的错误而失败。
是的,nginx.conf 是一个文件,它存在并在本地使用 docker-compose 时按预期工作。
另一个奇怪的事情是,如果我删除了该行(仅适用于链接到 /etc/nginx/nginx.conf 的 nginx.conf 文件)并将所述文件复制到它启动的 dockerfile 中的位置,但是它不能如果我这样做,请查看任何文件ls -la
我相信我们正在本地运行 gitlab 运行程序,并且我们之前已经在服务器上安装了 nginx。这可能是个问题吗?我们是否也应该在 docker 中运行 runner?
【问题讨论】:
-
似乎问题出在您的 Dockerfile 中...确保
/builds/project/whatever/docker/nginx/nginx.conf存在 -
@AlexKarshin 它确实存在,甚至没有在 dockerfile 中列出。如果我将其更改为 COPY nginx.conf /etc/nginx/nginx.conf 那么它在 CI 中工作正常
-
让我发布它作为答案,也许有人会遇到类似的问题
标签: docker docker-compose gitlab-ci