What do your two Dockerfiles look like?
What is supposed to be stored in the volume? (You might want to dump its contents to verify that the data in it is where you’re expecting it to be.)
Note from the docker volume docs:
If you start a container which creates a new volume, and the container has files or directories in the directory to be mounted such as
/app/
, Docker copies the directory’s contents into the volume. The container then mounts and uses the volume, and other containers which use the volume also have access to the pre-populated content.
Note that what it doesn’t say is that subsequent containers using that volume do not have their contents copied into the volume.
That’s a little more explicit in the tips section of the storage docs:
If you mount an empty volume into a directory in the container in which files or directories exist, these files or directories are propagated (copied) into the volume.
and
If you mount a bind mount or non-empty volume into a directory in the container in which some files or directories exist, these files or directories are obscured by the mount, …
What this means in practice is that only one of your containers will populate the volume. (This does seem to be a fairly common “gotcha” among people I know first working with docker compose.)