Доступ к docker .socket с использованием SE Linux в FCOS - PullRequest
2 голосов
/ 14 марта 2020

Intro

Привет,

Уже неделю я пытаюсь настроить FCOS (Fedora CoreOS) и запустить Docker Swarm вместе с SE Linux (это мой первый опыт с SE Linux)

Контейнеры работают отлично, но когда я пытаюсь использовать /var/run/docker.socket I ' m всегда получает 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]

Я уже пытался отключить SE Linux (setenforce 0), чтобы убедиться, что проблема возникает из SE Linux,

Info

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

Здесь docker -compose.yaml, который я использую для своих тестов

version: '3.2'

services:
  agent:
    image: portainer/agent
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:z      
      - /var/lib/docker/volumes:/var/lib/docker/volumes:z
    networks:
      - agent_network
    deploy:
      mode: global
      placement:
        constraints: [node.platform.os == linux]


networks:
  agent_network:
    driver: overlay
    attachable: true

Спасибо за вашу помощь!

1 Ответ

1 голос
/ 29 марта 2020

В отличие от CL (Container Linux), FCOS (Fedora CoreOS) поставляется с «целевой» политикой SE Linux, установленной на «принудительное». Если вы ожидаете того же поведения, что и в CL, вы должны установить «SELINUX = permissive» в /etc/selinux/config.

Вот CL / etc / selinux / config:

# This file controls the state of SELinux on the system on boot.

# SELINUX can take one of these three values:
#   enforcing - SELinux security policy is enforced.
#   permissive - SELinux prints warnings instead of enforcing.
#   disabled - No SELinux policy is loaded.
SELINUX=permissive

# SELINUXTYPE can take one of these four values:
#   targeted - Only targeted network daemons are protected.
#   strict   - Full SELinux protection.
#   mls      - Full SELinux protection with Multi-Level Security
#   mcs      - Full SELinux protection with Multi-Category Security 
#              (mls, but only one sensitivity level)
SELINUXTYPE=mcs

Вот FCOS / etc / selinux / config:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
...