setenforce 0
allowed the containers to start.
restorecon -Rv /
ran, but containers still exit immediately after I start them.
Perhaps this is the issue:
/docker/volumes not reset as customized by admin to system_u:object_r:container_file_t:s0
/docker/containers/a7b10d77cd670e77b28a715aec522b63a6280c665515b0219669f8aebdae901f/hostname not reset as customized by admin to system_u:object_r:container_file_t:s0:c564,c974
/docker/overlay2/1813fffbe7a50495466cc2f482de80326a5a1a987f8e90c14ba6c1bb435ac788/diff/run/secrets not reset as customized by admin to system_u:object_r:container_file_t:s0:c564,c974
Now, I know those labels matter to what containers can access what volumes in Docker. I’m pretty sure I didn’t manually change those files using something like chcon
.
$ history | grep chcon
734 sudo chcon -Rt svirt_sandbox_file_t /docker/
Oh. Well crap. I deleted that entire folder hierarchy once though using sudo rm -rf /docker
, after uninstalling docker, then I reinstalled and recreated the hierarchy.
Why would context remain for files like that?
$ sudo docker system prune
Deleted Containers:
ether
stone
Deleted Volumes:
ether-store
stone-store
Deleted Networks:
backend
Total reclaimed space: 160.8 MB
$ sudo docker volume create ether-store
ether-store
$sudo docker volume create stone-store
stone-store
$ sudo docker network create --internal backend
$ sudo docker run -dit --name ether --network backend -p 25000:80 -v ether-store:/var/www/html/:z -d php:7.0-apache
99279addfa591b2b3e1dd0d8bf64db7cfdac5f09ded6ac5e9a022ed71e768002
$ sudo docker run --name stone --network backend -v stone-store:/var/lib/mysql:z -e "MYSQL_ROOT_PASSWORD=You beckon me to the Cross. " -d mysql:latest
56b248eeced852453dddaf26b68b2050a571132364ef857c80211d50eafe6a53
$ sudo docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56b248eeced8 mysql:latest “docker-entrypoint…” 4 seconds ago Exited (1) 1 second ago stone
99279addfa59 php:7.0-apache “docker-php-entryp…” 18 seconds ago Exited (1) 14 seconds ago ether
$ sudo docker logs stone
standard_init_linux.go:178: exec user process caused “permission denied”
$ sudo docker logs ether
standard_init_linux.go:178: exec user process caused “permission denied”
The bit that adjusts the context on the files is the :z
at the end of the volume parameter on the docker run
command.
i.e. this: -v stone-store:/var/lib/mysql:z
This tags the volume’s files as :s0
in terms of context I believe.