Hi,
I’m developing a web application with Flask+nginx+MySQL with docker-compose, and having a build and test problem on CircleCI.
CircleCI jobs keep failing with error messages like:
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting “/home/circleci/xxx/nginx/nginx.conf” to rootfs at “/etc/nginx/nginx.conf”: mount /home/circleci/xxx/nginx/nginx.conf:/etc/nginx/nginx.conf (via /proc/self/fd/6), flags: 0x5000: 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
Environment
- Windows 11
- WSL2 Ubuntu 20.04.4
- Docker Desktop 4.10.1
- Docker Compose version v2.6.1
- Docker version 20.10.17, build 100c701
- docker-compose creates 3 containers: nginx, Flask, and MySQL.
The directry structure is like: (I omitted unrelevant files and directories)
.
├── app
│ └── Dockerfile
│ └── src/
├── docker-compose.yml
├── mysql
│ └── Dockerfile
└── nginx
├── Dockerfile
└── log
└── nginx/
└── nginx.conf
docker-compose.yml is like:
version: '3'
services:
db:
...
flask:
...
nginx:
build: ./nginx/
container_name: nginx
ports:
- '80:80'
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/log/nginx:/var/log/nginx
depends_on:
- flask
networks:
- front
...
nginx/Dockerfile is like:
FROM nginx:1.17.9
CMD ["nginx", "-g", "daemon off;", "-c", "/etc/nginx/nginx.conf"]
and, .circleci/config.yml is like:
version: 2
jobs:
build-and-test:
working_directory: ~/xxx
docker:
- image: cimg/python:3.7.13
steps:
- checkout
- run:
name: Copy envfiles
command: |
echo $MYSQL_ENV | base64 -di > mysql/envfile
echo $APP_ENV | base64 -di > app/src/tbl/.env
- setup_remote_docker
- run:
name: Start all services declared in docker-compose.yml
command: |
set -x
docker-compose up -d
- run:
working_directory: ~/xxx/app/src
name: Test
command: |
docker-compose exec flask pytest
...
workflows:
version: 2
workflows:
jobs:
- build-and-test
- deploy:
requires:
- build-and-test
filters:
branches:
only: master
What I confirmed and tried
nginx/nginx.conf
is definitely a file, and the target path/etc/nginx/nginx.conf
is also a file. So none of them is a directory as the error message says.- Removed
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
line in docker-compose.yml and addedCOPY nginx.conf /etc/nginx/nginx.conf
line in nginx/Dockerfile. Build succeeded but nginx.conf was not copied to the container so the nginx server did not work properly. - And, that code does work in my local environment.
I am totally stack and I would appreciate any advice.
Thank you in advance.