containers / containers/podman-compose

Use named volumes for mounting single files

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

Description

The [Docker-compose documentation](https://docs.docker.com/reference/compose-file/volumes/#driver_opts) shows how it is possible to create a named bind mount. It should be mapped to a specific host path.

Named volumes specification works fine for directories, but they do not work for mounting single files. Podman returns an error. I am not sure if the error comes from Podman or Podman-compose.

Maybe I have poorly configured the named volume (see the example).
```
2c880aa9dd451f26554719bc295b9f691b1046022eb04f79c7591801a88eb593
[SERVICE] | Error: unable to start container 2c880aa9dd451f26554719bc295b9f691b1046022eb04f79c7591801a88eb593: mounting volume VOLUME-NAME for container 2c880aa9dd451f26554719bc295b9f691b1046022eb04f79c7591801a88eb593: mount: /home/USERNAME/.local/share/containers/storage/volumes/VOLUME-NAME/_data: wrong fs type, bad option, bad superblock on VOLUME-SOURCE, missing codepage or helper program, or other error.
[SERVICE] | dmesg(1) may have more information after failed mount system call.
[SERVICE] |
```

Example:

```sh
# Set up a tmp file.
echo "hello world" > /tmp/test-file-source
```
```yaml
# docker-compose.yml
services:
# This service always work, for directories and files.
test_not_named:
image: alpine
volumes:
- type: bind
source: /tmp/test-file-source
target: /tmp/test-file-target
command: [ "cat", "/tmp/test-file-target" ]

# This service returns an error for files, only works with directories.
test_named:
image: alpine
volumes:
- test_named_volume:/tmp/test-file-target
command: [ "cat", "/tmp/test-file-target" ]
volumes:
test_named_volume:
driver: local
driver_opts:
type: bind
device: "/tmp/test-file-target"
o: "bind"
```

```sh
$ podman compose version
podman-compose version 1.6.0
podman version 5.8.2
```

**Describe the solution you'd like**

Possibility for named volumes to include named mounted files.

**Describe alternatives you've considered**

The first example works OK.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two services in the supplied docker-compose.yml with podman-compose 1.6.0 and Podman 5.8.2, comparing the direct bind mount with the named volume. Trace whether the failure belongs to podman-compose or Podman; done means the named volume mounts the single host file successfully, or the limitation and supported behavior are clearly established.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.