Dym*_*erz 7 selinux docker coreos docker-compose
问候,
一周以来,我一直在尝试设置FCOS (Fedora CoreOS) 并运行Docker Swarm和SELinux(这是我第一次使用 SELinux)
容器运行得很好,但是当我尝试使用时,/var/run/docker.socket我总是会遇到permission denied
portainer_agent.0.k9c6uqifwohk@localhost | 2020/03/14 13:24:11 [ERROR] [main,docker] [message: Unable to retrieve information from Docker] [error: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info: dial unix /var/run/docker.sock: connect: permission denied]
Run Code Online (Sandbox Code Playgroud)
我已经尝试禁用 SELinux ( setenforce 0) 以确保问题来自 SELinux,
docker.socket
srw-rw----. 1 root docker system_u:object_r:container_var_run_t:s0 0 Mar 14 13:14 /var/run/docker.sock
Run Code Online (Sandbox Code Playgroud)
这是我用于测试的 docker-compose.yaml
portainer_agent.0.k9c6uqifwohk@localhost | 2020/03/14 13:24:11 [ERROR] [main,docker] [message: Unable to retrieve information from Docker] [error: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info: dial unix /var/run/docker.sock: connect: permission denied]
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
我终于成功了,使用GitHub上的 dockersock.te
这是我在安装脚本中使用的函数:
function fix_socket_permission()
{
echo "Downloading docker socket policy"
sudo rpm-ostree install policycoreutils-python-utils
echo "Need reboot"
# need to reboot
curl https://raw.githubusercontent.com/dpw/selinux-dockersock/master/dockersock.te -o /tmp/dockersock.te
echo "Applying policy to system"
checkmodule -M -m -o dockersock.mod /tmp/dockersock.te
semodule_package -o dockersock.pp -m dockersock.mod
sudo semodule -i dockersock.pp
rm -rf /tmp/dockersock.te
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3122 次 |
| 最近记录: |