Open s4s0l opened 3 months ago
Hello @s4s0l
So it's a good catch, you identified a corner case error of the inline declaration 😅
What happened, when you use a config via a file declaration this one is mounted into the container even if the FS is in Read only mode. But it doesn't work the same with inline declaration, Compose write the content directly inside the container via a docker cp
command which will obviously failed when the FS is in RO
If you're block by this situation, I suggest you to use a config file instead of using the inline declaration as I supposed you don't want to change your container FS mode
Thanks for the explanation, I ended up mounting config as volume (It didn't occur to me that config via file declaration could work any different).
I just want to point out that inlined configs is a great feature. I can interpolate some env variables in config files right in compose file. Doing so with bind mounts or config via a file declaration, usually requires some scripting around;)
But it doesn't work the same with inline declaration, Compose write the content directly inside the container via a
docker cp
command which will obviously failed when the FS is in RO
Hello @glours I tried using an inline compose config on a read only container but with a tmpfs mount like so:
services:
test:
image: busybox
read_only: true
tmpfs:
- /config:mode=777
configs:
- source: test_config
target: /config/test_config
configs:
test_config:
content: config_content
But running docker compose up
(with docker 27.1.1
and compose 2.29.1
) still yields:
Error response from daemon: container rootfs is marked read-only
My intuition was that this should have worked because the config file copy should happen after the tmpfs is mounted, do you know when the copy happens exactly?
(As @s4s0l I'm asking because the inline configuration is quite useful, notably because it interprets environment variables like the rest of the compose file)
Hit this myself just now. Thanks for the explanation, @glours
Saves me from trying to understand why this isn't working. I completely agree with @guillaumedsde as inlining configs with env support is super handy. Would be super nice to have this working.
Description
I'm unable to attach config file to container when container has read-only filesystem.
Steps To Reproduce
docker compose up ends with:
Compose Version
Docker Environment
Anything else?
No response