containers / containers/podman-compose

Named bind volume is not mounted (unamed bind volume is mounted)

Open
#1,185 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Hello.

I will mount a same bind volume to host directory on multiple containers. Like with Docker (I am a Docker user, my new organisation wants to use Podman), I use a named volume for that. But, if I declare a named bind mount, "podman-compose up -d" create a local volume instead of binding to host directory.

If I declared the bind volume on each containers, it works.

**To Reproduce**
_Dockerfile_
```
FROM busybox:latest

ENTRYPOINT tail -f /dev/null
```

_docker-compose.yml_
```
volumes:
busybox-volume:
driver: local
driver_opts:
type: none
o: bind
device: ${PWD}

services:
busybox:
build:
context: .
dockerfile: Dockerfile
volumes:
- ${PWD}:/${HOME}/test
- busybox-volume:/${HOME}/test2
```

**Expected behavior**
Normally, "${HOME}/test" and "${HOME}/test2" should contain current host directory.
This code works correctly with Docker.

**Actual behavior**
"${HOME}/test" contains current host directory.
"${HOME}/test2" is empty.

**Output**

```
$ podman-compose version
['podman', '--version', '']
using podman version: 4.3.1
podman-composer version 1.0.3
podman --version
podman version 4.3.1

$ podman-compose up -d
['podman', '--version', '']
using podman version: 4.3.1
** excluding: set()
['podman', 'inspect', '-t', 'image', '-f', '{{.Id}}', 'busybox_busybox']
podman volume inspect busybox_busybox-volume || podman volume create busybox_busybox-volume
['podman', 'volume', 'inspect', 'busybox_busybox-volume']
Error: inspecting object: no such volume busybox_busybox-volume
['podman', 'volume', 'create', '--label', 'io.podman.compose.project=busybox', '--label', 'com.docker.compose.project=busybox', 'busybox_busybox-volume']
['podman', 'volume', 'inspect', 'busybox_busybox-volume']
['podman', 'network', 'exists', 'busybox_default']
podman run --name=busybox_busybox_1 -d --label io.podman.compose.config-hash=123 --label io.podman.compose.project=busybox --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=busybox --label com.docker.compose.project.working_dir=/home/lgallet/Dev/Busybox --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=busybox -v /home/lgallet/Dev/Busybox://home/lgallet/test -v busybox_busybox-volume://home/lgallet/test2 --net busybox_default --network-alias busybox busybox_busybox
0537233f0c999634db5e611917eb9c5c2632e706e02610902a53b219e0e8f3a2
exit code: 0

$ podman-compose exec busybox sh
['podman', '--version', '']
using podman version: 4.3.1
podman exec --interactive --tty busybox_busybox_1 sh

$ ls -l /home/lgallet/test
total 8
-rw-r--r-- 1 root root 96 Apr 14 13:54 Dockerfile
-rw-r--r-- 1 root root 274 Apr 14 14:34 docker-compose.yml

$ls -l /home/lgallet/test2
total 0
```
Podman-compose create an empty volume in place of binding to host directory.

**Environment:**
- OS: LMDE 6
- podman version: 4.3.1
- podman compose version: 1.0.3-3

**Additional context**

None.

Contributor guide

Open the contributing guide

Research direction

Start with the provided Dockerfile and docker-compose.yml, then reproduce the issue with podman-compose up -d and inspect the generated volume and container mounts. The fix is done when the named busybox-volume bind-mounts the current host directory so both /home/lgallet/test and /home/lgallet/test2 contain the host files.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.