X11 Authentication Error when run as a Docker container












0















I'm trying to run an application from a Docker container which is supposed to open a GUI widow (a video stream in my case). The Docker container is run on a Raspberry Pi and I SSH into the Pi from my Mac and then I issue the Docker run command. I have one problem here:



When I run the whole thing as follows, it works flawlessly:




  1. I run the command as:



docker run -it --net=host --device=/dev/vcsm --device=/dev/vchiq -e
DISPLAY -v /tmp/.X11-unix joesan/motion_detector bash






  1. From the bash, that opens up after issuing the Docker run command, I install xauth



    root@cctv:/raspi_motion_detection/project# apt-get install xauth



  2. I then add the Xauth cookie using Xauth add


  3. I then run my Python program which shows the GUI window with the video stream



So far so good. But, every time I don't want to be doing these steps all over again. So I wrote a small script to do this as below:



HOST=cctv

DISPLAY_NUMBER=$(echo $DISPLAY | cut -d. -f1 | cut -d: -f2)
echo $DISPLAY_NUMBER

# Extract auth cookie
AUTH_COOKIE=$(xauth list | grep "^$(hostname)/unix:${DISPLAY_NUMBER} " | awk '{print $3}')

# Add the xauth cookie to xauth
xauth add ${HOHOSTSTNAME}/unix:${DISPLAY_NUMBER} MIT-MAGIC-COOKIE-1 ${AUTH_COOKIE}

# Launch the container
docker run -it --net=host --device=/dev/vcsm --device=/dev/vchiq -e DISPLAY -v /tmp/.X11-unix joesan/motion_detector


But this time it fails with the error:



X11 connection rejected because of wrong authentication.
Unable to init server: Could not connect: Connection refused


I then tried to run the above script as a sudo user and I get the following:



xauth:  file /root/.Xauthority does not exist
xauth: (argv):1: bad "add" command line
X11 connection rejected because of wrong authentication.
Unable to init server: Could not connect: Connection refused


Is there anything that I'm missing? Please help!










share|improve this question























  • Did you run xhost + on the host?

    – Ricardo Branco
    Nov 13 '18 at 19:36











  • You mean run this command on my Mac? It fails because of a wrong authentication and I guess it is not related to doing xhost +

    – sparkr
    Nov 13 '18 at 19:42


















0















I'm trying to run an application from a Docker container which is supposed to open a GUI widow (a video stream in my case). The Docker container is run on a Raspberry Pi and I SSH into the Pi from my Mac and then I issue the Docker run command. I have one problem here:



When I run the whole thing as follows, it works flawlessly:




  1. I run the command as:



docker run -it --net=host --device=/dev/vcsm --device=/dev/vchiq -e
DISPLAY -v /tmp/.X11-unix joesan/motion_detector bash






  1. From the bash, that opens up after issuing the Docker run command, I install xauth



    root@cctv:/raspi_motion_detection/project# apt-get install xauth



  2. I then add the Xauth cookie using Xauth add


  3. I then run my Python program which shows the GUI window with the video stream



So far so good. But, every time I don't want to be doing these steps all over again. So I wrote a small script to do this as below:



HOST=cctv

DISPLAY_NUMBER=$(echo $DISPLAY | cut -d. -f1 | cut -d: -f2)
echo $DISPLAY_NUMBER

# Extract auth cookie
AUTH_COOKIE=$(xauth list | grep "^$(hostname)/unix:${DISPLAY_NUMBER} " | awk '{print $3}')

# Add the xauth cookie to xauth
xauth add ${HOHOSTSTNAME}/unix:${DISPLAY_NUMBER} MIT-MAGIC-COOKIE-1 ${AUTH_COOKIE}

# Launch the container
docker run -it --net=host --device=/dev/vcsm --device=/dev/vchiq -e DISPLAY -v /tmp/.X11-unix joesan/motion_detector


But this time it fails with the error:



X11 connection rejected because of wrong authentication.
Unable to init server: Could not connect: Connection refused


I then tried to run the above script as a sudo user and I get the following:



xauth:  file /root/.Xauthority does not exist
xauth: (argv):1: bad "add" command line
X11 connection rejected because of wrong authentication.
Unable to init server: Could not connect: Connection refused


Is there anything that I'm missing? Please help!










share|improve this question























  • Did you run xhost + on the host?

    – Ricardo Branco
    Nov 13 '18 at 19:36











  • You mean run this command on my Mac? It fails because of a wrong authentication and I guess it is not related to doing xhost +

    – sparkr
    Nov 13 '18 at 19:42
















0












0








0








I'm trying to run an application from a Docker container which is supposed to open a GUI widow (a video stream in my case). The Docker container is run on a Raspberry Pi and I SSH into the Pi from my Mac and then I issue the Docker run command. I have one problem here:



When I run the whole thing as follows, it works flawlessly:




  1. I run the command as:



docker run -it --net=host --device=/dev/vcsm --device=/dev/vchiq -e
DISPLAY -v /tmp/.X11-unix joesan/motion_detector bash






  1. From the bash, that opens up after issuing the Docker run command, I install xauth



    root@cctv:/raspi_motion_detection/project# apt-get install xauth



  2. I then add the Xauth cookie using Xauth add


  3. I then run my Python program which shows the GUI window with the video stream



So far so good. But, every time I don't want to be doing these steps all over again. So I wrote a small script to do this as below:



HOST=cctv

DISPLAY_NUMBER=$(echo $DISPLAY | cut -d. -f1 | cut -d: -f2)
echo $DISPLAY_NUMBER

# Extract auth cookie
AUTH_COOKIE=$(xauth list | grep "^$(hostname)/unix:${DISPLAY_NUMBER} " | awk '{print $3}')

# Add the xauth cookie to xauth
xauth add ${HOHOSTSTNAME}/unix:${DISPLAY_NUMBER} MIT-MAGIC-COOKIE-1 ${AUTH_COOKIE}

# Launch the container
docker run -it --net=host --device=/dev/vcsm --device=/dev/vchiq -e DISPLAY -v /tmp/.X11-unix joesan/motion_detector


But this time it fails with the error:



X11 connection rejected because of wrong authentication.
Unable to init server: Could not connect: Connection refused


I then tried to run the above script as a sudo user and I get the following:



xauth:  file /root/.Xauthority does not exist
xauth: (argv):1: bad "add" command line
X11 connection rejected because of wrong authentication.
Unable to init server: Could not connect: Connection refused


Is there anything that I'm missing? Please help!










share|improve this question














I'm trying to run an application from a Docker container which is supposed to open a GUI widow (a video stream in my case). The Docker container is run on a Raspberry Pi and I SSH into the Pi from my Mac and then I issue the Docker run command. I have one problem here:



When I run the whole thing as follows, it works flawlessly:




  1. I run the command as:



docker run -it --net=host --device=/dev/vcsm --device=/dev/vchiq -e
DISPLAY -v /tmp/.X11-unix joesan/motion_detector bash






  1. From the bash, that opens up after issuing the Docker run command, I install xauth



    root@cctv:/raspi_motion_detection/project# apt-get install xauth



  2. I then add the Xauth cookie using Xauth add


  3. I then run my Python program which shows the GUI window with the video stream



So far so good. But, every time I don't want to be doing these steps all over again. So I wrote a small script to do this as below:



HOST=cctv

DISPLAY_NUMBER=$(echo $DISPLAY | cut -d. -f1 | cut -d: -f2)
echo $DISPLAY_NUMBER

# Extract auth cookie
AUTH_COOKIE=$(xauth list | grep "^$(hostname)/unix:${DISPLAY_NUMBER} " | awk '{print $3}')

# Add the xauth cookie to xauth
xauth add ${HOHOSTSTNAME}/unix:${DISPLAY_NUMBER} MIT-MAGIC-COOKIE-1 ${AUTH_COOKIE}

# Launch the container
docker run -it --net=host --device=/dev/vcsm --device=/dev/vchiq -e DISPLAY -v /tmp/.X11-unix joesan/motion_detector


But this time it fails with the error:



X11 connection rejected because of wrong authentication.
Unable to init server: Could not connect: Connection refused


I then tried to run the above script as a sudo user and I get the following:



xauth:  file /root/.Xauthority does not exist
xauth: (argv):1: bad "add" command line
X11 connection rejected because of wrong authentication.
Unable to init server: Could not connect: Connection refused


Is there anything that I'm missing? Please help!







docker x11






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 16:48









sparkrsparkr

5,0731243108




5,0731243108













  • Did you run xhost + on the host?

    – Ricardo Branco
    Nov 13 '18 at 19:36











  • You mean run this command on my Mac? It fails because of a wrong authentication and I guess it is not related to doing xhost +

    – sparkr
    Nov 13 '18 at 19:42





















  • Did you run xhost + on the host?

    – Ricardo Branco
    Nov 13 '18 at 19:36











  • You mean run this command on my Mac? It fails because of a wrong authentication and I guess it is not related to doing xhost +

    – sparkr
    Nov 13 '18 at 19:42



















Did you run xhost + on the host?

– Ricardo Branco
Nov 13 '18 at 19:36





Did you run xhost + on the host?

– Ricardo Branco
Nov 13 '18 at 19:36













You mean run this command on my Mac? It fails because of a wrong authentication and I guess it is not related to doing xhost +

– sparkr
Nov 13 '18 at 19:42







You mean run this command on my Mac? It fails because of a wrong authentication and I guess it is not related to doing xhost +

– sparkr
Nov 13 '18 at 19:42














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285801%2fx11-authentication-error-when-run-as-a-docker-container%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285801%2fx11-authentication-error-when-run-as-a-docker-container%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python