container icon indicating copy to clipboard operation
container copied to clipboard

[Bug]: `container` daemon hangs when `container cp` from a mounted volume

Open bittervec opened this issue 5 months ago • 3 comments

I have done the following

  • [x] I have searched the existing issues
  • [ ] If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

  1. Create a named volume: container volume create some-vol
  2. Start a temporary container to transfer data: container run -d --name temp-importer -v some-vol:/target alpine tail -f /dev/null
  3. Now depending on the src/dst setup the behavior is different.

Volume as dst: copy from the host to the mounted volume

container cp /path/to/host/src temp-importer:/target

The command didn't seem to have any effects even with --debug option.

  • No output from CLI
  • No files in the /target folder of the temp container (except for lost+found)

Volume as src: copy from the mounted volume to the host

Then I did another test the other away around.

After manually creating a file with touch /target/hi in the temp container, I tried to copy from the mounted volume to the host:

container cp temp-importer:/target/hi /path/to/host/dst

The command was stuck and the daemon simply became unresponsive afterwards.

Problem description

I was initially trying to migrate some data from the host to a volume created with container, and found out container cp didn't work once a mounted volume is involved, either as source or destination.

  • no-ops when copying from the host to the mounted volume
  • container daemon hangs when copying from the mounted volume to the host

Logs

Can't locate any logs.

❯ container system logs --debug
Filtering the log data using "subsystem ==[cd] "com.apple.container""
Timestamp                       Thread     Type        Activity             PID    TTL
--------------------------------------------------------------------------------------------------------------------
Log      - Default:          0, Info:                0, Debug:             0, Error:          0, Fault:          0
Activity - Create:           0, Transition:          0, Actions:           0

Environment

- OS: macOS 26.5.1 (25F80)
- Xcode: N/A
- Container: Container CLI version 1.0.0

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

bittervec avatar Jun 30 '26 13:06 bittervec

This is a known limitation — container cp doesn't handle Virtualization.framework's filesystem passthrough reliably for mounted volumes. Until it's fixed, the workaround is to use container exec with a direct copy command inside the container:

container exec <container-name> cp -a /mounted/path/file /destination/

For migrating data into a new container, you can also use a shared bind mount as an intermediate: mount the same host directory in both containers, then copy from within. Full migration guide covering this and other gotchas: https://maccontainer.dev/compose-alternative/

Jakeshadow avatar Jul 01 '26 07:07 Jakeshadow

Additional data point: still reproducible on 1.5.0, also affects bind mounts (virtiofs), and the data silently lands in the rootfs layer underneath the mountpoint.

Reproduced on container CLI 1.5.0 (brew), macOS 27.0.1 arm64, alpine:latest.

container volume create v1
container run -d --name b -v v1:/dane alpine sleep infinity
echo HELLO > plik.txt
container cp plik.txt b:/dane/plik.txt ; echo $?        # 0
container exec b cat /dane/plik.txt                    # No such file or directory
container exec b mount | grep dane                     # /dev/vdc on /dane type ext4
container exec b sh -c 'echo X > /dane/inside.txt'
container cp b:/dane/inside.txt ./out.txt              # Error ... notFound: copy: path not found '/dane/inside.txt'
container stop b && container export -o b.tar b && tar tf b.tar | grep dane
# dane/  dane/plik.txt   <- the file is in the rootfs layer under the mountpoint

Same with -v /host/dir:/dane (virtiofs): cp returns 0, file absent in the container and on the host, but present in container export output.

Control: container cp plik.txt b:/tmp/plik.txt works. tar -c plik.txt | container exec -i b tar -x -C /dane works.

Expected: cp resolves the path as the running container sees it (through mounts), or fails with a non-zero exit code. Actual: exit 0 and data silently lands in the masked rootfs directory; copy out of mounted paths fails with notFound (on 1.5.0 the daemon no longer hangs).

Log: only copyIn xpc handler [uuid=b], no error.

magnimodi avatar Oct 13 '26 15:10 magnimodi

Still reproduces on 1.6.1 / macOS 27.2 (and 1.5.0 / 27.0.1 on a second machine), same as the 13 Oct report.

One more consequence, for anyone searching: CI runners can't work on container through a Docker-API shim. With socktainer, act / forgejo-runner copy step scripts into a volume mounted at /var/run/act and read result files back, so every step fails with bash: /var/run/act/workflow/0: No such file or directory. A shim that does PUT/GET …/archive with exec tar -x / tar -c inside the container makes the same job pass — the same workaround davit adopted in wouterdebie/davit#32. Tools around container are each working around this on their own.

Tigeneric avatar Oct 31 '26 12:10 Tigeneric