Closed TheGroxEmpire closed 1 week ago
I tried to reproduce without success relying on a minimal setup:
$ cat compose.yaml
services:
test:
image: alpine
volumes:
./foo/bar.txt:/foo/bar.txt
$ mkdir foo
$ echo "hello" > foo/bar.txt
$ docker compose run test ls -al foo
[+] Running 1/1
drwxr-xr-x 2 root root 4096 Jun 25 14:08 .
drwxr-xr-x 1 root root 4096 Jun 25 14:08 ..
-rw-r--r-- 1 root root 6 Jun 25 14:07 bar.txt
If you want a file to be bind-mounted you indeed need the source to exist before (otherwise engine will assume directory)
For you ruse-case, can't you bind mount the whole directory instead ? i.e. ./crowdsec:/etc/crowdsec
@TheGroxEmpire hi! execute docker rm {containerId}
to remove old container.
You created a docker container that has a bound volume with destination /etc/crowdsec/acquis.yaml
and acquis.yaml
is directory, because at the first time when you create the container you had no local file and docker created it as directory, but after you created local file and it sees that you want to bind local file to container's directory.
How to reproduce:
services:
test:
image: alpine
volumes:
./foo/bar.txt:/foo/bar.txt
docker compose up -d
touch ./foo/bar.txt
docker-compose up -d
How to fix: remove old container
@ndeloof Is this a bug or is it done on purpose so that when you create a container with volume, but you don't have a source file/folder, docker creates such a directory?
this is indeed default docker engine behavior.
Description
I am trying to deploy Crowdsec with docker compose. The volumes config requires it to create acquis.yaml file in its volumes.
However, docker created acquis.yaml file as directory instead of yaml file. I tried forcing the docker to create the yaml file by making an empty acquis.yaml file in the host. But it outputs an error instead:
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 "/home/opc/docker/crowdsec/acquis.yaml" to rootfs at "/etc/crowdsec/acquis.yaml": mount /home/opc/docker/crowdsec/acquis.yaml:/etc/crowdsec/acquis.yaml (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
Steps To Reproduce
docker compose up -d
on this config https://github.com/crowdsecurity/example-docker-compose/blob/main/npm/docker-compose.yml.docker compose up -d
again.Compose Version
Docker Environment
Anything else?
Other person encountering the same issue: https://discourse.crowdsec.net/t/cant-start-docker-container-acquis-yaml-is-a-directory/1891/6