Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to mount /var/run/docker.sock #585

Closed
visualex opened this issue Jul 28, 2020 · 11 comments
Closed

unable to mount /var/run/docker.sock #585

visualex opened this issue Jul 28, 2020 · 11 comments

Comments

@visualex
Copy link

visualex commented Jul 28, 2020

[core@fedor ~]$ rpm-ostree status
State: idle
Deployments:
● ostree://fedora:fedora/x86_64/coreos/testing
                   Version: 32.20200715.2.2 (2020-07-16T23:28:30Z)
                    Commit: b911874d6a927d4025c534d10c24da80d3706e1f04aa541e10e2799f34274690
              GPGSignature: Valid signature by 97A1AE57C3A2372CCA3A4ABA6C13026D12C944D0

when moving logs from containers to ELK we use logspout,
the idea is that the global service mounts the docker.sock in swarm:

volumes:
      - /var/run/docker.sock:/var/run/docker.sock

On the original CoreOS there was no issue:

core@coreos ~ $ ls -al /var/run/docker.sock
srw-rw----. 1 root docker 0 Jul 27 01:25 /var/run/docker.sock

but the same on Fedora CoreOS

[core@fedor ~]$ ls -al /var/run/docker.sock
srw-rw----. 1 root docker 0 Jul 27 01:25 /var/run/docker.sock

does not work,

the container outputs:

# logspout v3.2.6-custom by gliderlabs
# adapters: raw udp tcp multiline logstash
# options : persist:/mnt/routes
# jobs    : routes http[]:80 pump
# routes  :
#   ADAPTER		ADDRESS		CONTAINERS	SOURCES	OPTIONS
#   multiline+logstash	192.168.0.3:5000			map[]
2020/07/28 12:10:46 pump ended: Get http://unix.sock/containers/json?: dial unix /var/run/docker.sock: connect: permission denied

what permissions are required here?
thanks

@visualex visualex changed the title unable to mount unable to mount /var/run/docker.sock Jul 28, 2020
@dustymabe
Copy link
Member

One good first thing to check is SELinux. If you put SELinux in permissive mode (setenforce 0) does it work?

@Siosm
Copy link

Siosm commented Jul 28, 2020

https://danwalsh.livejournal.com/78373.html could help here.

@visualex
Copy link
Author

setenforce 0 works,
since docker swarm does not have --privileged or --security-opt
flags for services, whats the best way to make sure Fedora CoreOS is started with SELinux in permissive mode?
Thanks again

@travier
Copy link
Member

travier commented Jul 29, 2020

You should edit /etc/selinux/config and set SELINUX=disabled (or change it at first boot via Igntion). Permissive mode is only there for development or debug.

In your case I don't understand why you could not run the initial container with --privileged. Could you give us a little more details?

@travier
Copy link
Member

travier commented Jul 29, 2020

See also the suggestions from portainer/portainer#849 & https://github.com/dpw/selinux-dockersock

@dustymabe
Copy link
Member

@visualex - can we close this out? Are you unblocked?

@visualex
Copy link
Author

Hi! whats the best way to do it via ignition, could you provide an example please?
After that I think we can close this yes.
Thank you!

@travier
Copy link
Member

travier commented Aug 31, 2020

whats the best way to do it via ignition, could you provide an example please?

Which option did you choose? Did you get it working with SELinux?

@visualex
Copy link
Author

visualex commented Sep 4, 2020

@travier yes, I used your advice here: #585 (comment)
how can I provide this in a yaml ignition file, whats the best approach?
thank you

@travier
Copy link
Member

travier commented Sep 7, 2020

If you added the --privileged flag to a podman or docker invocation then you should add this to the unit you're using to start the container.
If you want to disable SELinux on first boot via Ignition (not recommended, you should really try other options before):

systemd:
  units:
  - name: kargs-setup.service
    enabled: true
    contents: |
      [Unit]
      Description=Setup additional kernel arguments on first boot
      ConditionFirstBoot=true
      Wants=basic.target
      Before=multi-user.target
      [Service]
      Type=oneshot
      ExecStart=/usr/bin/rpm-ostree kargs --append selinux=0 --reboot
      [Install]
      WantedBy=basic.target

@visualex
Copy link
Author

visualex commented Sep 7, 2020

awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants