moby: Cannot run container with systemd in it on macOS
Hi,
I did a bit of research around this and, event though it looks like there is a way to work around this problem, this is not applicable to Docker users running it on macOS.
OS version:
macOS Sierra, 10.12.3
Docker version:
Client:
Version: 1.13.0
API version: 1.25
Go version: go1.7.3
Git commit: 49bf474
Built: Wed Jan 18 16:20:26 2017
OS/Arch: darwin/amd64
Server:
Version: 1.13.0
API version: 1.25 (minimum version 1.12)
Go version: go1.7.3
Git commit: 49bf474
Built: Wed Jan 18 16:20:26 2017
OS/Arch: linux/amd64
Experimental: true
Command & error received:
$ systemctl daemon-reload
Failed to get D-Bus connection: Unknown error -1
How to reproduce:
host> docker run -ti --cap-add=SYS_ADMIN -e "container=docker" -v $PWD:/app debian:jessie /sbin/init
container> bash -c 'export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -qqy curl python build-essential python-dev libssl-dev
container> systemctl daemon-reload
Please let me know if you need anymore info. Thank you.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 15 (6 by maintainers)
So far I’m satisfied with
$ docker run -d -e=container=docker --stop-signal=SIGRTMIN+3 --cap-add=SYS_ADMIN --security-opt=seccomp:unconfined -v /sys/fs/cgroup:/sys/fs/cgroup:ro centos:7 /sbin/init
You may want to do
systemctl mask systemd-machine-id-commit
https://bugzilla.redhat.com/show_bug.cgi?id=1472439I was able to get systemd to work in a ubuntu:16.04 Docker container on a MacOS host by adding the following options to my
docker-compose.yml
.Hope this helps.
credit and references:
I’m on OS X. There’s no such
/sys/fs/cgroup
I can mount a volume from.@justincormack to give you an update, by adding
-v /sys/fs/cgroup:/sys/fs/cgroup:ro
the container starts but then I get asked for login…Full output of container launch follows:
I’m able to remove the
--security-opt=seccomp:unconfined
flag now that there is a--tmpfs
flag:https://github.com/moby/moby/issues/9950#issuecomment-442713669
@walterdolce that will work on Docker for Mac, it only mounts the configured directories from the OSX host, all the rest are mounted from the VM.
This is not mac specific, you just have
systemd
configured incorrectly so it is trying to talk to host dbus (which does not exist, but it is a good thing as this would be messing with host system), and you are missing sometmpfs
mounts and various other things it needs to run.You need to least
-v /sys/fs/cgroup:/sys/fs/cgroup:ro
; I think you need a few moretmpfs
mounts, will try to find the docs.