dockermacosdocker-composemacos-ventura

Docker-compose volumes on MacOS Ventura (13.1) are all empty


I'm running into an issue with MacOS Ventura where by all bind volumes - where I link a directory on my host machine to one on the container - created with docker-compose are empty. I've tested the same scripts on MacOS 12.4 and 12.6 and they work as expected giving me the same directory contents on the container as on the host, so it seems v13 changed some permission.

The docker-compose.yml file:

version: "3"

services:
  bash:
    image: ubuntu:latest
    stdin_open: true
    tty: true
    volumes:
      - ./:/app
    command: "/bin/bash"

So this should be creating a directory on the container called /app and linking that to the host directory the compose file is in.

But when I start the container:

❯ docker-compose up --build
[+] Running 1/0
 ⠿ Container ruby-docker-bash-1  Created                                                             0.0s
Attaching to ruby-docker-bash-1

And login, the /app directory is empty:

❯ docker exec -it ruby-docker-bash-1 /bin/bash
root@9644de175d48:/# cd app/
root@9644de175d48:/app# ls -la
total 4
drwxr-xr-x 2 root root   40 Feb  1 09:59 .
drwxr-xr-x 1 root root 4096 Feb  1 09:39 ..

The total 4 is really weird here as there are 4 files supposed to be there, but not accessible:

root@9644de175d48:/app# cat Gemfile
cat: Gemfile: No such file or directory

This is the directory contents on the host are:

❯ ls -la
.rw-r--r-- 2.7k paul  1 Feb 09:31 Dockerfile
.rw-r--r-- 3.9k paul  1 Feb 09:32 Gemfile
.rw-r--r--  27k paul  1 Feb 09:32 Gemfile.lock
.rw-r--r--  149 paul  1 Feb 10:00 docker-compose.yml

If anyone has any experience with what might be going wrong or how I can get past this absolute time-sink of an issue, I'd really appreciate it.

Thank you!


Solution

  • I figured it out. I use Colima on MacOS, as there is no MacOS VM by docker.

    Then I found this comment on a Colima repo issue, https://github.com/abiosoft/colima/issues/500#issuecomment-1343103477, where a user had mentioned they weren't able to sync directories.

    To fix volumes on MacOS, using Colima, I did the folowing:

    colima delete # reset
    colima start --mount-type 9p
    

    This doesn't seem to be documented anywhere. I’ve been through the site, the readme.

    I’m in MacOS 13, so it seems like there are issues with virtiofs and not in the older 9p mount type.