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

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

Closed
275288698 opened this Issue Jul 15, 2015 · 7 comments

Comments

9 participants
@275288698

275288698 commented Jul 15, 2015

When I in a Ubuntu systemctl use, I get:

$ systemctl --user
Failed to get D-Bus connection: Operation not permitted
$ systemctl --system
Failed to get D-Bus connection: Operation not permitted

$ busctl --user
Failed to connect to bus: No such file or directory

when i do this ,it works

$ busctl --system
NAME PID PROCESS USER
:1.0 1 init root
:1.1 565 avahi-daemon avahi
....

//===============================
here is my environment:
Ubuntu14.04
systemd 221 install by source
//=================================

how can i fix it ?
waiting for ur help

@dvdhrm

This comment has been minimized.

Show comment
Hide comment
@dvdhrm

dvdhrm Jul 15, 2015

Member

First of all, please use the newest release (which is systemd-222). Secondly, please make sure you build systemd compatible to the needs of your distribution. This usually means copying the script from the systemd-build-script of upstream. We cannot support random systemd builds combined with existing distributions.

What exactly is the reason you build systemd by yourself? If you need local modifications, please use the build-tools of your distribution, which usually allows patches on packages before building them.

Member

dvdhrm commented Jul 15, 2015

First of all, please use the newest release (which is systemd-222). Secondly, please make sure you build systemd compatible to the needs of your distribution. This usually means copying the script from the systemd-build-script of upstream. We cannot support random systemd builds combined with existing distributions.

What exactly is the reason you build systemd by yourself? If you need local modifications, please use the build-tools of your distribution, which usually allows patches on packages before building them.

@dvdhrm dvdhrm self-assigned this Jul 15, 2015

@zonque

This comment has been minimized.

Show comment
Hide comment
@zonque

zonque Jul 15, 2015

Member

For instance, building for Ubuntu requires you to pass --enable-split-usr --with-rootprefix=/ during ./configure. @mbiebl and @martinpitt are the experts for systemd on Debian/Ubuntu around here :)

Member

zonque commented Jul 15, 2015

For instance, building for Ubuntu requires you to pass --enable-split-usr --with-rootprefix=/ during ./configure. @mbiebl and @martinpitt are the experts for systemd on Debian/Ubuntu around here :)

@martinpitt

This comment has been minimized.

Show comment
Hide comment
@martinpitt

martinpitt Jul 15, 2015

Contributor

Sorry, not "d-bus". Ubuntu 14.04 does not use systemd, you can't use it there yet. The first Ubuntu release where systemd is officially supported is 15.04, and it barely works on 14.10.

Contributor

martinpitt commented Jul 15, 2015

Sorry, not "d-bus". Ubuntu 14.04 does not use systemd, you can't use it there yet. The first Ubuntu release where systemd is officially supported is 15.04, and it barely works on 14.10.

@martinpitt martinpitt closed this Jul 15, 2015

@poettering poettering added the sd-bus label Jul 27, 2015

@kgrvamsi

This comment has been minimized.

Show comment
Hide comment
@kgrvamsi

kgrvamsi Aug 17, 2015

Even if we use Ubuntu 15.04 This issue is the same @martinpitt i face it when i was trying to enable some of the services in one of the docker containers

Output

Created symlink from /etc/systemd/system/multi-user.target.wants/flannel.service to /etc/systemd/system/flannel.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-apiserver.service to /etc/systemd/system/kube-apiserver.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-controller-manager.service to /etc/systemd/system/kube-controller-manager.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-scheduler.service to /etc/systemd/system/kube-scheduler.service.
Failed to get D-Bus connection: Operation not permitted

kgrvamsi commented Aug 17, 2015

Even if we use Ubuntu 15.04 This issue is the same @martinpitt i face it when i was trying to enable some of the services in one of the docker containers

Output

Created symlink from /etc/systemd/system/multi-user.target.wants/flannel.service to /etc/systemd/system/flannel.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-apiserver.service to /etc/systemd/system/kube-apiserver.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-controller-manager.service to /etc/systemd/system/kube-controller-manager.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-scheduler.service to /etc/systemd/system/kube-scheduler.service.
Failed to get D-Bus connection: Operation not permitted
@dorvan

This comment has been minimized.

Show comment
Hide comment
@dorvan

dorvan Sep 25, 2015

the same on gentoo, with docker and after the mount -o bind of /dev, /proc, /sys in a dir for chroot

dorvan commented Sep 25, 2015

the same on gentoo, with docker and after the mount -o bind of /dev, /proc, /sys in a dir for chroot

@ozbillwang

This comment has been minimized.

Show comment
Hide comment
@ozbillwang

ozbillwang Jan 18, 2016

an answer from docker:
moby/moby#7459

ozbillwang commented Jan 18, 2016

an answer from docker:
moby/moby#7459

@kuncao

This comment has been minimized.

Show comment
Hide comment
@kuncao

kuncao Mar 23, 2018

solution:with -rm optiion such as
docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro --privileged -d -p 18002:18002 -p 1127:1127 -p 2222:22 --rm --ip 172.20.0.3 --net smbridge -h SmServer --shm-size=36G --name secom secom:v1
[root@SmServer packagessm]# pwd
/root/packagessm
[root@SmServer packagessm]# ls
PreInstall_CentOS7.1.zip SecoManager_5.1.0.B010_ALL_install_config.zip
[root@SmServer packagessm]# systemctl
UNIT LOAD ACTIVE SUB DESCRIPTION
dev-xvda1.device loaded activating tentative /dev/xvda1
-.mount loaded active mounted /
dev-mqueue.mount loaded active mounted POSIX Message Queue File System
etc-hostname.mount loaded active mounted /etc/hostname
etc-hosts.mount loaded active mounted /etc/hosts
etc-resolv.conf.mount loaded active mounted /etc/resolv.conf
sshd-keygen.service loaded active exited OpenSSH Server Key Generation
sshd.service loaded active running OpenSSH server daemon
systemd-journald.service loaded active running Journal Service
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
-.slice loaded active active Root Slice
system.slice loaded active active System Slice
dbus.socket loaded active listening D-Bus System Message Bus Socket
systemd-journald.socket loaded active running Journal Socket
systemd-shutdownd.socket loaded active listening Delayed Shutdown Socket
basic.target loaded active active Basic System
local-fs.target loaded active active Local File Systems
multi-user.target loaded active active Multi-User System
paths.target loaded active active Paths
slices.target loaded active active Slices
sockets.target loaded active active Sockets
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
timers.target loaded active active Timers
systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup of Temporary Directories
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
25 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
-------------other information----------------
--------------base image dockerfile----------
FROM centos:7
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" ]
#######added 20180322
ADD cmd.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/cmd.sh
CMD ["/usr/local/bin/cmd.sh"]
#######added 20180322
#######changed 20180322
#CMD ["/usr/sbin/init"]
#######changed 20180322

cmd.sh file when compile base image
#!/bin/bash
exec /usr/sbin/init # To correctly start D-Bus thanks to https://forums.docker.com/t/any-simple-and-safe-way-to-start-services-on-centos7-systemd/5695/8

-----------------------business dockerfile------------------------------------------
########################## build secomanager dockerfile ###########################
FROM local/c7-systemd
MAINTAINER caokun caokun.nj@huawei.com
ENV container docker
ENV TZ Asia/Shanghai
ENV http_proxy c00286473:password@proxyus3.huawei.com:8080/
ENV https_proxy c00286473:password@proxyus3.huawei.com:8080/
ENV all_proxy c00286473:password@proxyus3.huawei.com:8080/
ENV no_proxy=127.0.0.1,.huawei.com,localhost,local,.local,10.120.165.217,*.huawei.com
RUN yum install -y openssh-server vim telnet sudo wget unzip tar gcc openssl lsof service compat-libstdc++-33 systemctl strace
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
RUN useradd guest
RUN echo "guest:guest!@#" | chpasswd
RUN echo "guest ALL=(ALL) ALL" >> /etc/sudoers
RUN echo "root:Mylinux1" | chpasswd
RUN sed -i '1s/^/set encoding=utf-8\n/' /etc/vimrc
&& echo "set hls" >> /etc/vimrc
&& echo "set expandtab" >> /etc/vimrc
&& echo "set sw=4" >> /etc/vimrc
&& echo "set tabstop=4" >> /etc/vimrc
RUN sudo mkdir /root/packagessm
ADD files/PreInstall_CentOS7.1.zip /root/packagessm/
ADD files/SecoManager_5.1.0.B010_ALL_install_config.zip /root/packagessm/
WORKDIR /root/packagessm
#WORKDIR /root
RUN sudo mkdir /var/run/sshd
#############for ssh
#EXPOSE 22
#ENTRYPOINT /usr/sbin/sshd -D
#############for ssh
CMD ["/usr/sbin/init"]

command to build base image
docker build --rm -t local/c7-systemd .
command bo build business image
docker build --rm -t secom:v1 .

other information
[root@szvphicpra31005 Sm_Docker]# docker --version
Docker version 17.03.0-ce, build 3a232c8
docker 内的os
[root@SmServer packagessm]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

kuncao commented Mar 23, 2018

solution:with -rm optiion such as
docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro --privileged -d -p 18002:18002 -p 1127:1127 -p 2222:22 --rm --ip 172.20.0.3 --net smbridge -h SmServer --shm-size=36G --name secom secom:v1
[root@SmServer packagessm]# pwd
/root/packagessm
[root@SmServer packagessm]# ls
PreInstall_CentOS7.1.zip SecoManager_5.1.0.B010_ALL_install_config.zip
[root@SmServer packagessm]# systemctl
UNIT LOAD ACTIVE SUB DESCRIPTION
dev-xvda1.device loaded activating tentative /dev/xvda1
-.mount loaded active mounted /
dev-mqueue.mount loaded active mounted POSIX Message Queue File System
etc-hostname.mount loaded active mounted /etc/hostname
etc-hosts.mount loaded active mounted /etc/hosts
etc-resolv.conf.mount loaded active mounted /etc/resolv.conf
sshd-keygen.service loaded active exited OpenSSH Server Key Generation
sshd.service loaded active running OpenSSH server daemon
systemd-journald.service loaded active running Journal Service
systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
-.slice loaded active active Root Slice
system.slice loaded active active System Slice
dbus.socket loaded active listening D-Bus System Message Bus Socket
systemd-journald.socket loaded active running Journal Socket
systemd-shutdownd.socket loaded active listening Delayed Shutdown Socket
basic.target loaded active active Basic System
local-fs.target loaded active active Local File Systems
multi-user.target loaded active active Multi-User System
paths.target loaded active active Paths
slices.target loaded active active Slices
sockets.target loaded active active Sockets
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
timers.target loaded active active Timers
systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup of Temporary Directories
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
25 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
-------------other information----------------
--------------base image dockerfile----------
FROM centos:7
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" ]
#######added 20180322
ADD cmd.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/cmd.sh
CMD ["/usr/local/bin/cmd.sh"]
#######added 20180322
#######changed 20180322
#CMD ["/usr/sbin/init"]
#######changed 20180322

cmd.sh file when compile base image
#!/bin/bash
exec /usr/sbin/init # To correctly start D-Bus thanks to https://forums.docker.com/t/any-simple-and-safe-way-to-start-services-on-centos7-systemd/5695/8

-----------------------business dockerfile------------------------------------------
########################## build secomanager dockerfile ###########################
FROM local/c7-systemd
MAINTAINER caokun caokun.nj@huawei.com
ENV container docker
ENV TZ Asia/Shanghai
ENV http_proxy c00286473:password@proxyus3.huawei.com:8080/
ENV https_proxy c00286473:password@proxyus3.huawei.com:8080/
ENV all_proxy c00286473:password@proxyus3.huawei.com:8080/
ENV no_proxy=127.0.0.1,.huawei.com,localhost,local,.local,10.120.165.217,*.huawei.com
RUN yum install -y openssh-server vim telnet sudo wget unzip tar gcc openssl lsof service compat-libstdc++-33 systemctl strace
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
RUN useradd guest
RUN echo "guest:guest!@#" | chpasswd
RUN echo "guest ALL=(ALL) ALL" >> /etc/sudoers
RUN echo "root:Mylinux1" | chpasswd
RUN sed -i '1s/^/set encoding=utf-8\n/' /etc/vimrc
&& echo "set hls" >> /etc/vimrc
&& echo "set expandtab" >> /etc/vimrc
&& echo "set sw=4" >> /etc/vimrc
&& echo "set tabstop=4" >> /etc/vimrc
RUN sudo mkdir /root/packagessm
ADD files/PreInstall_CentOS7.1.zip /root/packagessm/
ADD files/SecoManager_5.1.0.B010_ALL_install_config.zip /root/packagessm/
WORKDIR /root/packagessm
#WORKDIR /root
RUN sudo mkdir /var/run/sshd
#############for ssh
#EXPOSE 22
#ENTRYPOINT /usr/sbin/sshd -D
#############for ssh
CMD ["/usr/sbin/init"]

command to build base image
docker build --rm -t local/c7-systemd .
command bo build business image
docker build --rm -t secom:v1 .

other information
[root@szvphicpra31005 Sm_Docker]# docker --version
Docker version 17.03.0-ce, build 3a232c8
docker 内的os
[root@SmServer packagessm]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

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