docker container error "Failed to get D-Bus connection: Operation not permitted" - docker-container

getting error"Failed to get D-Bus connection: Operation not permitted" while using systemctl command for restarting service in centos container.

use below command to start the docker container.
docker run -d -it --privileged ContainerId /usr/sbin/init
use docker file from below link for fix this issue. when run the docker image use --privileged.
https://hub.docker.com/_/centos
add these lines to docker file

Related

Cannot use pintos by ssh

I use a docker container to try pintos on my mac(M1). Everything behaves well when I start the container by docker start -i pintos.
However, when I use ssh to connect my docker container(i.e., ssh -p xxxx root#local), error message -bash: pintos: command not found occurs if I try pintos -- in directory /pintos/src/threads/build.

docker run -v bindmount failing

I am rather new to docker images and am trying to set up a selenium/standalone-firefox image linked to a local folder.
I'm running Docker version 19.03.2, build 6a30dfc on Windows 10 and have unsuccessfully tried figuring out the correct working of the docker run -v syntax because it either is unspecific (i.e. too little context for me to make sense of it) or on the wrong platform).
Running docker as admin the the cmd, I used docker run -d -v LOCAL_PATH:C:\Users\Public.
This throws docker: Error response from daemon: invalid mode: \Users\Public as an error message.
I want to bind the running container to the folder C:\Users\Public (or another folder on the host machine - this is for illustration purposes).
Can someone point me to the (I fear obvious) mistake I'm making? I essentially want to achieve the container's output data (for later scraping) being stored in the host machine's folder C:\Users\Public. The container's output folder should be named myfolder.
** EDIT **
Digging around, I found this (see Volume Mapping).
I have thus tried the following code:
>docker run -d -p 4444:4444 --name selenium-hub selenium/hub
>docker run -d --link selenium-hub:hub -v C:/Users/Public:/home/seluser/Downloads selenium/node-chrome
while the former works fine (it only runs the container), the latter throws the error:
docker: Error response from daemon: Drive has not been shared.
Docker for Windows (and Mac) require you to share drives to be able to volume mount - https://docs.docker.com/docker-for-windows/ (Under Shared drives).
You should be able to find it under your Docker Settings > Shared Drives. Ensure your C:\ is selected and restart the daemon. After that, you can run:
docker run -d --link selenium-hub:hub -v C:/Users/Public:/home/seluser/Downloads selenium/node-chrome
base on the documation:
https://github.com/SeleniumHQ/docker-selenium
this path does not exist in container and its linux container.
"C:\Users\Public\Documents\TMP_DOCKERS\firefox selenium/standalone-firefo"

openthread/environment docker rsyslogd: imklog: cannot open kernel log (/proc/kmsg): Operation not permitted

I am running openthread/environment:latest docker image (as of 2019-06-15)
When starting on a fresh ubuntu 18.04 with docker 18.09 using the command
ubuntu#ip-172-31-37-198:~$ docker run -it --rm openthread/environment bash
I get the following output
Stopping system message bus dbus [ OK ]
Starting system message bus dbus [ OK ]
Starting enhanced syslogd rsyslogd
rsyslogd: imklog: cannot open kernel log (/proc/kmsg): Operation not permitted
rsyslogd: activation of module imklog failed [v8.32.0 try http://www.rsyslog.com/e/2145 ]
Anyone knows whether this is related to ubuntu setup or the docker container or how to fix.
#Reto's answer will work, but you will be editing that file every time you build your container. Put this in your Dockerfile and you're all set. The edit will be performed automatically while the container is being built.
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
You will also get rid of this warning if you just comment out the line
module(load="imklog")
inside your Docker container (edit /etc/rsyslog.conf).
I doubt you want to read the kernel messages inside a container ;-)
Try adding the --privileged option.
For example:
docker run -it --rm --privileged openthread/environment bash

How to run container using image id or name?

I have created an apache server image from tar file using below command,
cat /home/ubuntu/docker-work/softwares/httpd-2.4.27.tar.gz | docker import - httpd:2.4
The image is created successfully and its name is httpd!
I have run below command,
docker run -d -p 80:80 --name=apache httpd:2.4
which is giving error,
docker: Error response from daemon: No command specified.
How do I run the above image using the name(httpd) ?
The error that you are getting means that the image import from the tar doesn't container a default command CMD line to start the container.
Docker allows you to not specify the CMD in the docker file, however in that case you need to provide the command when doing docker run. Example:
docker run -d -p 80:80 --name=apache httpd:2.4 httpd-foreground
Where httpd-foreground is the command that will start the httpd server process inside the container.

Redis server fails to start in docker

I have a docker image 'redis_image' that installed redis in it. After I run a container as:
docker run --name test_redis -it redis_image bash
the redis server can start normally in the container using '/etc/init.d/redis start'.
But if I run the container with --net=host option, the redis server will fail to start in the container, it says "Starting redis-server: could not open session [Failed]". Is the problem related to the --net=host configuration when I run the container? Thanks.