tech687
(Tech687)
February 12, 2025, 8:36am
1
+ cat compose.yml
services:
test:
image: scratch
volumes:
- type: bind
source: ~/bin
target: ~/bin
read_only: true
Now a little attention
+ docker compose config | grep /bin
source: /home/USER/bin
target: ~/bin
But, as last line, I expected
target: /home/USER/bin
Explanation?
bluepuma77
(Bluepuma77)
February 12, 2025, 10:33am
2
The source
is on the current node, so compose can expand the ~
to the full home path.
The target
is inside the (to be run) container, compose doesn’t know what user is going to be used inside, so it keeps the ~
in place.
1 Like
tech687
(Tech687)
February 12, 2025, 12:56pm
3
Thanks.
But
+ cat compose.yml
services:
test:
extends:
file: ~/xxx
service: xxx
+ docker compose config
cannot read ~/xxx
Why, also in this case, the tilde is not interpolated (/home/USER/xxx)?
cavo789
(Christophe Avonture)
February 12, 2025, 3:36pm
4
OS variables are expanded. You can then use ${HOME}
1 Like
tech687
(Tech687)
February 12, 2025, 5:24pm
5
mmmhhh… but I would like the expansion to be done inside the container
├── 1.yml
├── 2.yml
└── Dockerfile
+ cat 1.yml
services:
test:
build: .
volumes:
- type: bind
source: ~/bin
target: /home/internal-user/bin
read_only: true
command: sh -c "ls -d ~/bin"
+ cat 2.yml
services:
test:
build: .
volumes:
- type: bind
source: ~/bin
target: ~/bin
read_only: true
command: sh -c "ls -d ~/bin"
+ cat Dockerfile
FROM ubuntu:latest
RUN apt-get update \
&& apt-get -y install gettext-base \
&& groupadd \
-g 1234 \
internal-user \
&& useradd \
-m \
-s /bin/bash \
-u 1234 \
-g internal-user \
internal-user
USER internal-user:internal-user
Let’s do some tests
+ docker compose --file 1.yml run --rm test
/home/internal-user/bin
OK
+ docker compose --file 2.yml run --rm test
Error response from daemon: invalid mount config for type "bind": invalid mount path: '~/bin' mount path must be absolute
Any solutions?
1 Like
system
(system)
Closed
February 22, 2025, 5:24pm
6
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.