containers / containers/podman-compose

volume mounted as type "bind" instead of "volume"

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

Description

Hi all,
I'm training myself Podman based on a Dock course and faced an issue with podman-compose related to volumes. My docker-compose.yml files looks like this (environment directives have been removed):
```
version: '3'
services:
postgres:
image: 'postgres:latest'
redis:
image: 'redis:latest'
server:
build:
dockerfile: Dockerfile.dev
context: ./server
volumes:
- /app/node_modules
- ./server:/app
```
The Dockerfile.dev among other activities runs "npm install" and thereby populates a directory "node_modules" with lots of dependencies.

If I execute "podman-compose up" everything is set up and started, but the nodejs server fails to start. I analysed the output of "podman-compose up" and found our what's causing my problem, it's the "--mount" option of "podman start". The two relevant commands executed by "podman-compose" are:
```
podman volume inspect complex_server_2ad5d7cee913d733ad04aafde20a26db || podman volume create complex_server_2ad5d7cee913d733ad04aafde20a26db
Error: no volume with name "complex_server_2ad5d7cee913d733ad04aafde20a26db" found: no such volume
podman create --name=complex_server_1 --pod=complex --label io.podman.compose.config-hash=123 --label io.podman.compose.project=complex --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=server -e REDIS_HOST=redis -e REDIS_PORT=6379 -e PGUSER=postgres -e PGHOST=postgres -e PGDATABASE=postgres -e PGPASSWORD=postgrep_password -e PGPORT=5432 --mount type=bind,source=/home/mschmitz/.local/share/containers/storage/volumes/complex_server_2ad5d7cee913d733ad04aafde20a26db/_data,destination=/app/node_modules,bind-propagation=Z --mount type=bind,source=/home/mschmitz/work/various-tests/podman/images/complex/./server,destination=/app --add-host postgres:127.0.0.1 --add-host complex_postgres_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host complex_redis_1:127.0.0.1 --add-host server:127.0.0.1 --add-host complex_server_1:127.0.0.1 complex_server
```

Using "--mount type=bind,source=/home/mschmitz/.local/share/containers/storage/volumes/complex_server_2ad5d7cee913d733ad04aafde20a26db/_data,destination=/app/node_modules,bind-propagation=Z" results in entirely hiding the content of the images "node_modules" directory. This is exactly should happen according to the Docker documentation.

However, it's different from what happens when using "docker-compose". Like "podman-compose" a volume is created, but it's not mounted as a "bind mount", but a "volume".

Therefore I executed all "podman" commands which "podman-compose" executes but changed the "podman create" command mentioned above as regards the first "--mount" option. Using "--mount type=volume,source=complex_server_2ad5d7cee913d733ad04aafde20a26db" does the job. Podman populates the volume with the content of the image, nodejs finds all dependencies and starts up.

To me it looks like the command issued by "podman-compose" to mount a volume must be changed.

BR,
Michael.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.