Tiryoh / docker-ros2-desktop-vnc

🐳 Dockerfiles to provide HTML5 VNC interface to access Ubuntu Desktop + ROS 2
https://memoteki.net/archives/2955
Apache License 2.0
417 stars 83 forks source link

Can't connect to local host after 1st time #100

Open The-Michael-Chen opened 1 year ago

The-Michael-Chen commented 1 year ago

I was trying to run ros foxy on a docker container. It works fine launching it for the first time, but after I run docker stop container it doesn’t connect anymore to the localhost port. It still works in terminal, but doesn’t work with novnc in the browser.

The command I ran to initialize it was docker create -it -p 6080:80 -v $(pwd):/home/ubuntu/Desktop/yondu_ros --name ros2_gazebo --volumes-from ros2_practice tiryoh/ros2-desktop-vnc:foxy

I'm running it on MacOS Ventura 13.1

I’m not getting any errors except on the browser where it says “failed to connect to server”

Tiryoh commented 1 year ago

Hi @The-Michael-Chen,

Can you provide complete instructions to reproduce? Is it possible that both the first container and the container that is launched with the docker create command are both trying to use port 6080 on the host machine?

The-Michael-Chen commented 1 year ago

Hey @Tiryoh . Thank you so so much for offering to help! I make sure to close the container after opening so I don't think two containers are trying to use port 6080 on the host machine. The complete steps to reproduce are as follows:

docker create -it -p 6080:80 --name ros2_example tiryoh/ros2-desktop-vnc:foxy It always works fine the first time. (I've tried it without -it, without the binding, and without the volumes from and it still doesn't work) docker stop ros2_example docker start ros2_example After that, it doesn't work with local host anymore. But, it still works while running in terminal.

Different things I've tried:

  1. I've tried checking for port conflicts. When I run lsof -i :6080 before restarting the container, nothing comes up. When running it during the container it only comes up with the correct port mapping. As I mentioned earlier I've also tried various ports.
  2. I've tried restarting my laptop and docker many times
  3. I've tried different browsers to ensure it wasn't an issue with cache
  4. I tried on my friends Mac and had the same issue. On my other friend's windows it worked fine.
suzuki-takuo commented 1 year ago

For your information, a friend of mine told me that logging out before stopping the container can avoid the problem. Thanks.

The-Michael-Chen commented 1 year ago

@suzuki-takuo crazy enough that works! Why would that work lmao

The-Michael-Chen commented 1 year ago

could we see this issue get resolved @Tiryoh

Tiryoh commented 1 year ago

@The-Michael-Chen Sorry, I've missed the notification I'm glad to hear that the issue has been resolved!

@suzuki-takuo Thanks for your help!

Once I confirm that the issue and its solution can be reproduced, I'm planning to make an addition to the README.