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

Failed to get D-Bus connection: Operation not permitted #45

Open
Treverix opened this issue Jan 9, 2016 · 7 comments
Open

Failed to get D-Bus connection: Operation not permitted #45

Treverix opened this issue Jan 9, 2016 · 7 comments

Comments

@Treverix
Copy link

Treverix commented Jan 9, 2016

When trying to build an image based on this Dockerfile:

FROM centos:latest
MAINTAINER andreas.dolk@mpi.lu

# systemd (Source: https://github.com/docker-library/docs/tree/master/centos#systemd-integration)
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]

# Apache
RUN yum install -y httpd httpd-devel
RUN chkconfig httpd on
RUN apachectl start

the last step fails:

Step 9 : RUN apachectl start
 ---> Running in 70e7de9def6a
Failed to get D-Bus connection: Operation not permitted
The command '/bin/sh -c apachectl start' returned a non-zero code: 1

The lines below the systemd comment have been copied from the docs today (see reference in the comment)

@rickalm
Copy link

rickalm commented May 4, 2016

I ran across this when trying to solve a similar DBUS problem

#41

Hope it helps

@xichengc
Copy link

@Treverix I am having the same problem. Have you solved this? Thanks.

@jamshid
Copy link

jamshid commented Dec 23, 2016

Not sure but most instructions about centos and systemd in docker out outdated. See this for current working instructions:
moby/moby#28614 (comment)

I don't think you can run services via systemd in a docker build. Special privileges are needed. You can only enable / disable services, e.g.:
RUN systemctl enable dnsmasq

If you need to run apache during the build maybe you could instead run it in foreground:
RUN apachectl -D FOREGROUND & sleep 30 && curl -i localhost

If you need your container startup CMD to run a bash script before starting systemd init (e.g. to do some configuration based on env variables), that works if the script ends by calling exec /usr/sbin/init.

@tmarshall
Copy link

I'm having the same problem, on OSX 10.11.6 (El Capitan). Docker version 1.11.1, build 5604cbe.

My app is trying to start up Postgres 9.5.

Running:

docker run -i -t \
  --privileged \
  -p 80:3000 \
  --cap-add SYS_ADMIN \
  -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
  --dns 4.4.4.4 --dns 8.8.4.4 \
  -e NODE_ENV="${NODE_ENV}" \
  tmarshall/latest bash;

My Dockerfile builds off of the same given in https://hub.docker.com/_/centos/ (see "Dockerfile for systemd base image").

There was also an older thread that mentioned a fix for Ubuntu users, which I tried to apply to OSX, via -v $(mktemp):/run but that did not help.

No matter what, I always get

Redirecting to /bin/systemctl start  postgresql-9.5.service
Failed to get D-Bus connection: Operation not permitted

@tmarshall
Copy link

^ I got it to work by referring to @zokeber's repo, docker-postgresql

@tuanpht
Copy link

tuanpht commented Feb 7, 2018

I can run systemd in Centos 7 with this command:

docker run --tmpfs /run -v /sys/fs/cgroup:/sys/fs/cgroup:ro -d centos:7 /sbin/init

More references:

@kuncao
Copy link

kuncao commented Mar 23, 2018

please refer
docker-library/docs#1177

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

No branches or pull requests

7 participants