Docker mount $HOME/.config/path/file:/root/.config/path/file: succeeds mount, but no files on dest container

I hope I’m putting this question in the right place.

I am using Ubuntu 24.04 LTS. This is a fresh re-install.

I’m trying to migrate a container from my previous server. I rebuilt the image. When I attempt to run it with two mounts, one of the mounts does not actually mount anything. There are no errors from docker and the inspection shows that the mounts exist.

docker run -dp 80:80/tcp -p 443:443/tcp --network proxy-network \
  --add-host myserver:192.168.100.1 --name nginx-proxy \
  --mount type=bind,src="/etc/ssl/certs/nginx",target="/etc/ssl/certs/nginx"\
  --mount type=bind,src="$HOME/.config/dynu/config",target="/root/.config/dynu/config.json":ro \
  vproj-nginx:latest

The mount to /etc/ssl... succeeds. However, on the host, the config.json never exists. I’ve tried mounting that to various locations in the container and it never succeeds. I’m at a loss. I’ve never seen this happen before and I did not have this problem in Ubuntu 22.04 LTS. Documentation suggested running sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0, which did not solve the problem.

note that I have verified the file on the source-host side. It exists. It never gets “placed”/mounted on the container side. I’ve tried running the container as sudo and also I have tried --privileged. Nothing works.

❯ docker version
Client:
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.22.2
 Git commit:        24.0.7-0ubuntu4
 Built:             Wed Apr 17 20:08:25 2024
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.22.2
  Git commit:       24.0.7-0ubuntu4
  Built:            Wed Apr 17 20:08:25 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.12
  GitCommit:
 runc:
  Version:          1.1.12-0ubuntu3
  GitCommit:
 docker-init:
  Version:          0.19.0
  GitCommit:
 ❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04 LTS
Release:        24.04
Codename:       noble
❯ uname -a
Linux myserver 6.8.0-38-generic #38-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun  7 15:25:01 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

I think this is a bug so I’ve posted an issue in github: Docker mount $HOME/.config/path/file:/root/.config/path/file: succeeds mount, but no files on dest container · Issue #5287 · docker/cli · GitHub

As it was suggested on GitHub, I agree that you should install Docker from the official repository. The Docker IO is maintained by Ubuntu and it is based on Moby as Docker CE, but it is not the same. I tried Docker CE on Ubuntu 24.04 and tried to mount something from a similar source path under “$HOME/.config/...” and it worked for me.

EDIT:

And to answer your note on GitHub, no, there is nothing wrong with posting the question on the forum and on GitHub, especially when you give us the links to the other topic.

it’s embarrassing but I just found out what I was doing wrong. I was invoking my test of the running image by using docker run instead of docker exec sigh

No problem. So just because I didn’t understand first, you mean you ran a container using your original command you shared in your question, and then ran docker run -it imagename command instead of docker exec -it containername command to test the mount, right? That happens, don’t worry :slight_smile: