DOCKER — D-Bus connection: Operation not permitted ERROR ?
A blog for docker error rectification and troubleshooting of few generic errors i.e. faced by many users.
Few days back i was trying to set up few test machines for one my project using docker and for same i decided to use centos image i.e. to be used to spin up few containers.
I started off with docker pull centos image , created a container using docker run command , entered into a container using docker exec command and then post updating yum repositories installed the Apache on my container.
Till this point all goes well so, now next step was to start apache and update my code but when i tried to start apache got an error : Failed to get D-Bus connection: Operation not permitted, Oh stuck !
Have you got the same error ? Or in a same position like me ? Don’t worry i am going to help you out with the below steps to overcome above problem and with few more issues that came on my way while troubleshooting.
1. Steps to reproduce
Below is steps of issue replication i.e. Failed to get D-Bus connection: Operation not permitted
i) docker pull
ii) docker run
Setting up a preprod container(centos image) in an internal network i.e. dockernetwork and with capabilities to operate network related operations(- -cap-add=NET_ADMIN).
iii) docker exec
Jump onto the container using docker exec and install apache.
iv) The error
Start apache and here is an error!
2. Issue Rectification
Below steps to be followed.
- Modify earlier docker run command and pass /usr/sbin/init as command (CMD) that is to have systemd init processes support inside the container.
2. Now login onto the container and try installing and running apache , if success then well done else you might get an another error (as in my case) i.e. Error response from daemon: cgroups: cannot find cgroup mount destination: unknown.
Success
Fail
IF response == FAIL
THEN
To rectify the last error , we need to modify default docker-machine environment setup and have to create and mount cgroup directory as a partition for systemd.
SSH into docker default machine
Create & Mount
Retry
Retry the setup of container , installation of apache and try to start the httpd services, it should be success this time.
Success!
— A blog by teckdevOps