Error checking context: 'can't stat '/home/user/docker-project' when runing docker build
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snappy |
Invalid
|
Undecided
|
Unassigned |
Bug Description
gary@ubuntu:
snap 2.23.1
snapd 2.23.1
series 16
ubuntu 16.04
kernel 4.4.0-67-generic
To reproduce the issue:
1. install the docker snap from stable channel
sudo snap install docker
2. check if home interface is connected (actually, it's auto-connected)
snap interfaces
3. get the test app and put it under home directory
bzr branch lp:~gary-wzl77/+junk/test_build ~/test_build
4. go to the docker project folder and try to build
cd ~/test_build && sudo docker build -t hello-world .
Error checking context: 'can't stat '/home/
5. check the syslog
Mar 21 07:33:54 ubuntu kernel: [155777.026938] audit: type=1400 audit(149005283
*.Similar apparmor denies error occurs when running docker.compose
*.Put the project file under ~/apps/docker/ or ~/snap/docker/ ,try to re-build and get the same error.
*.Someone already had the same issue running "docker build" with the docker-snap in the store
https:/
Changed in snappy: | |
status: | New → Invalid |
Okay, I found the root cause why docker build and docker compose doesn't work for me now.
Regarding the "Error checking context: 'can't stat "
We have apparmor policy for the read-only home area
owner @{HOME} /snap/@ {SNAP_NAME} / r, /snap/@ {SNAP_NAME} /** mrkix,
owner @{HOME}
and read/write home area in @{HOME} if home interface is declared in yaml file and connected
owner @{HOME}/ r, /{s,sn, sna}{,/ } rwk,
owner @{HOME}/[^s.] rwk,
owner @{HOME}/s[^n] rwk,
owner @{HOME}/sn[^a] rwk,
owner @{HOME}/sna[^p] rwk,
owner @{HOME}
I'm carrying over habits from snap command with sudo. However when I pre-append "sudo" in docker command it turns out the read/write home area ending up to
/root/
instead of user's $HOME
/home/gary/ (in my case)
That's why I see the "apparmor denies" error when running the following command
cd ~/test_build && sudo docker build -t hello-world .
after removing sudo, image can be generated successfully.
However with docker(docker.io deb package), running sudo docker
works well and image can be created as usual.
That's the difference in the usage of docker between deb package and snap package at this point.