docker-compose.yml contains the following
services:
unbound-db-socket:
image: busybox:latest
container_name: unbound-db-socket
init: true
tty: true
command: [/bin/sh -c "chown -R 1000:1000 /usr/local/unbound/cachedb.d/"]
volumes:
- "cachedb.d:/usr/local/unbound/cachedb.d/"
volumes:
cachedb.d:
networks:
bridge:
When running docker compose up, I'm getting the error
"unbound-db-socket | [FATAL tini (7)] exec /bin/sh -c "chown -R 1000:1000 /usr/local/unbound/cachedb.d/" failed: No such file or directory"
What am I doing wrong?
Added [] to the command Added "" to the volume path
docker-compose.yml contains the following
services:
unbound-db-socket:
image: busybox:latest
container_name: unbound-db-socket
init: true
tty: true
command: [/bin/sh -c "chown -R 1000:1000 /usr/local/unbound/cachedb.d/"]
volumes:
- "cachedb.d:/usr/local/unbound/cachedb.d/"
volumes:
cachedb.d:
networks:
bridge:
When running docker compose up, I'm getting the error
"unbound-db-socket | [FATAL tini (7)] exec /bin/sh -c "chown -R 1000:1000 /usr/local/unbound/cachedb.d/" failed: No such file or directory"
What am I doing wrong?
Added [] to the command Added "" to the volume path
Share Improve this question asked Mar 10 at 19:41 BrunnBrunn 31 bronze badge 2 |1 Answer
Reset to default 0BusyBox
uses sh -c
differently, and tini
is trying to execute the whole command as a binary rather than passing it to the shell.
Modify command like this:
command: ["/bin/sh", "-c", "mkdir -p /usr/local/unbound/cachedb.d && chown -R 1000:1000 /usr/local/unbound/cachedb.d/"]
This ensures the directory exists before attempting to change ownership.
Output
docker-compose.yml
file after update
services:
unbound-db-socket:
image: busybox:latest
container_name: unbound-db-socket
init: true
tty: true
command: ["/bin/sh", "-c", "mkdir -p /usr/local/unbound/cachedb.d && chown -R 1000:1000 /usr/local/unbound/cachedb.d/"]
volumes:
- "cachedb.d:/usr/local/unbound/cachedb.d/"
volumes:
cachedb.d:
networks:
bridge:
[]
– Eternal Dreamer Commented Mar 10 at 20:03[/bin/sh, -c, "chown -R ..."]
. This usage doesn't need thesh -c
wrapper and I'd remove it. Also remember that thecommand:
is the only thing the container will do, so this container will exit immediately once it's run thechown
command. – David Maze Commented Mar 10 at 20:09