Docker: Could not connect to any X display - docker

Although the container should have the needed privileges to connect to the display, I got this error each time:
docker exec -it my_container
/# rqt
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
No protocol specified
QXcbConnection: Could not connect to display :1
Could not connect to any X display.
The following command has been used to run the container:
sudo docker run -itd --restart unless-stopped --name my_container --privileged --net=host --gpus all \
--env="NVIDIA_DRIVER_CAPABILITIES=all" \
--env="DISPLAY=$DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
my_image:v1.1

The solution is to run the following command in your terminal:
xhost +local:docker
Then try again, it should work:
docker exec -it my_container
/# rqt
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'

Related

podman not running container in quay setup in centos9

I am setting up quay in a vm with centos distro. This is the guide I am following: quay deploy guide
once I install Podman I am trying to run first container with below command:
I set up this env variable:
export QUAY=QUAY
and made a dir of same name in home:
mkdir QUAY
once I install Podman I am trying to run first container with below command:
$ sudo podman run -d --rm --name postgresql-quay \
-e POSTGRESQL_USER=quayuser \
-e POSTGRESQL_PASSWORD=quaypass \
-e POSTGRESQL_DATABASE=quay \
-e POSTGRESQL_ADMIN_PASSWORD=adminpass \
-p 5432:5432 \
-v $QUAY/postgres-quay:/var/lib/pgsql/data:Z \
registry.redhat.io/rhel8/postgresql-10:1
and I am getting following error:
sudo podman run -d --rm --name postgresql-quay -e POSTGRESQL_USER=quayuser -e POSTGRESQL_PASSWORD=quaypass -e POSTGRESQL_DATABASE=quay -e POSTGRESQL_ADMIN_PASSWORD=adminpass -p 5432:5432 -v QUAY/postgres-quay:/var/lib/pgsql/data:Z registry.redhat.io/rhel8/postgresql-10:1
Error: error creating named volume "QUAY/postgres-quay": error running volume create option: names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*: invalid argument
The bind mount needs to be specified as an absolute path or a relative path that starts with ./ or ../.
In other words instead of
-v QUAY/postgres-quay:/var/lib/pgsql/data:Z
use
-v ./QUAY/postgres-quay:/var/lib/pgsql/data:Z
(I replaced $QUAY with its value QUAY)

How to have 2 containers connect to other container using TCP in docker network

I have this right now:
docker network rm cprev || echo;
docker network create cprev || echo;
docker run --rm -d -p '3046:3046' \
--net=cprev --name 'cprev-server' cprev-server
docker run --rm -d -p '3046:3046' \
-e cprev_user_uuid=111 --net=cprev --name 'cprev-agent-1' cprev-agent
docker run --rm -d -p '3046:3046' \
-e cprev_user_uuid=222 --net=cprev --name 'cprev-agent-2' cprev-agent
basically the 2 cprev-agents are supposed to connect to the cprev-server using TCP. The problem is I am getting this error:
docker: Error response from daemon: driver failed programming external
connectivity on endpoint cprev-agent-1
(6e65bccf74852f1208b32f627dd0c05b3b6f9e5e7f5611adfb04504ca85a2c11):
Bind for 0.0.0.0:3046 failed: port is already allocated.
I am sure it's a simple fix but frankly I don't know how to allow two way traffic from the two agent containers without using the same port etc.
So this worked (using --network=host) but I am wondering how I can create a custom network that doesn't interfere with the host network??
docker network create cprev; # unused now
docker run --rm -d -e cprev_host='0.0.0.0' \
--network=host --name 'cprev-server' "cprev-server:$curr_uuid"
docker run --rm -d -e cprev_host='0.0.0.0' \
-e cprev_user_uuid=111 --network=host --name 'cprev-agent-1' "cprev-agent:$curr_uuid"
docker run --rm -d -e cprev_host='0.0.0.0' \
-e cprev_user_uuid=222 --network=host --name 'cprev-agent-2' "cprev-agent:$curr_uuid"
so is there anyway to get this to work using my custom docker network "cprev"?

Docker Run Failed Due to --log-opts

I am running a docker run command to spawn a new container. The command I gave:
docker run -h 'activemq1' --net bridge -m 20g --env-file /opt/dockerenv/activemq-1/env.txt -p 8161:8161 -p 61613:61613 -p 61614:61614 -p 61616:61616 -p 1616:1616 -p 5672:5672 -p 1883:1883 -v /opt/dckexchange:/exchange -v /etc/yum.repos.d:/etc/yum.repos.d -v /mnt/data/volumes/activemq1/data:/usr/share/activemq/data --log-opt max-size=1g --log-opt max-file=2 --name activemq-dev mydocker:5000/activemq/activemq:latest
It should be running perfectly without error, but apparently it throws me an error unknown flag: --log-opts. It is running ok if I remove all of the log-opt command.
Docker version: 1.13.1
Any ideas?
Maybe you're missing the log-driver e.g.
--log-driver json-file --log-opt max-size=1g --log-opt max-file=2
I think you need this unless you've specified a default in /etc/docker/daemon.json

How to run TensorBoard in Docker container without root privileges?

I am running tensorflow-gpu in a Docker container.
At the moment I am only able to run and access TensorBoard when I access the running Docker container using root privileges. I would like to accomplish this without using root privileges. How can this be accomplished?
Here some information on what I am doing and what worked out:
I am running a tensorflow-gpu using the provided docker containers from TensorFlow using the following command.
$ docker run \
-u $(id -u username):$(id -g username) \
-it --rm --runtime=nvidia \
-v $(realpath ~/data/workspace/notebooks):/tf/notebooks \
-v $(realpath ~/data/workspace/):/tf/workspace \
-v $(realpath ~/data/images/):/tf/images \
-p 8888:8888 -p 6007-6015:6007-6015 tensorflow/tensorflow:2.0.0a0-gpu-py3-jupyter
In the command line for starting container I added additional ports for TensorBoard.
I accomplished to run TensorBoard when doing the following.
The container is running (using the commands above for startup)
→ each attempt to run and access the TensorBoard out of the running Jupyter notebook fails
From the docker host PC I run the following commands:
$ docker psto get the container name
$ sudo docker exec -it <container name> bash
→ I tried this with and without sudo, without the command below will not work
tf-docker /tf > tensorboard --logdir <log directory> --port 6007
Now I am able to access the TensorBoard on localhost:6007
I am new to Docker, TensorFlow, and I am a newcomer to Linux (Ubuntu).
I would like to accomplish what I described above without the usage of root privileges.
Is there a way to do it without?
What would be the best/correct way?
What is your best practice advice?
Edit 2019-06-24:
I do not know why it did not workout in the first place, perhaps I used the wrong port. This is what I accomplished until now.
I start the container using the following command line where I changed the port for TensorBoard to 6006
$ docker run \
-u $(id -u username):$(id -g username) \
-it --rm --runtime=nvidia \
-v $(realpath ~/data/workspace/notebooks):/tf/notebooks \
-v $(realpath ~/data/workspace/):/tf/workspace \
-v $(realpath ~/data/images/):/tf/images \
-p 8888:8888 -p 6006:6006 tensorflow/tensorflow:2.0.0a0-gpu-py3-
jupyter
Then from the command line I start a bash shell inside the docker container without using root privileges: $ docker exec -it <container name> bash
After that, I start TensorBoard and use the link in the out put in a webbrowser: tf-docker /tf > tensorboard --logdir <log directory> --port 6007
Instead of the previous command I could also start Tensorboard from Jupyter notebook.
%reload_ext tensorboard.notebook
%tensorboard --logdir=<log directory> --port=6006
Edit 2019-10-09:
Since using the TensorFlow 2.0.0 release with TensorBoard 2.0.0 I have to start TensorBoard the following:
$ tensorboard --logdir=<log directory> --host 0.0.0.0 --port 6006
Without explicitly adding the host option it does not work.
The steps I followed and I could visualise the results with tensorboard:
when creating a the container, open/map an external port for tensorboard:
> nvidia-docker run -d --name tkra_tensorb --ipc=host -it -p 8513:8090
> -p 3014:6006 -v /data:/data tkra_tb
inside the container, run tensorboard:
> tensorboard --logdir /data/tkra/MyDatasets/resnet101/checkpoints/
> --host 0.0.0.0 --port 6006
Open tensorboard in my browser: <server_address>:3014

docker saucelabs : invalid reference format

I have gone through this article http://www.testautomationguru.com/selenium-webdriver-disposable-selenium-grid-infrastructure-setup-using-zalenium Integrating with Cloud Testing Platforms:
I have already added sauce username and access key in Environment variables. It docker, Zalenium works without Saucelabs but with saucelabs gives error: docker.exe: invalid reference format.
Without Saucelabs - works fine:
docker run --rm -ti --name zalenium -p 4444:4444
-v /var/run/docker.sock:/var/run/docker.sock
-v /tmp/videos:/home/seluser/videos --privileged dosel/zalenium start
With Saucelabs - gives formatting error:
docker run --rm -ti --name zalenium -p 4444:4444 -p 5555:5555 \
-e SAUCE_USERNAME
-e SAUCE_ACCESS_KEY \
-v /tmp/videos:/home/seluser/videos \
-v /var/run/docker.sock:/var/run/docker.sock \ dosel/zalenium start --sauceLabsEnabled true
I am using Docker Toolbox on Windows 7
Already took reference of:
docker: invalid reference format in shell script
docker : invalid reference format
Docker command returns "invalid reference format"
My mistake was - I was using back slash \. After removing it from command it worked. After removing it becomes
docker run --rm -ti --name zalenium -p 4444:4444 -p 5555:5555
-e SAUCE_USERNAME
-e SAUCE_ACCESS_KEY
-v /tmp/videos:/home/seluser/videos
-v /var/run/docker.sock:/var/run/docker.sock dosel/zalenium start --sauceLabsEnabled true
Take care of unnecessary space also.

Resources