1

i have created a docker image. Then i run it with command docker run -d -p 5901:5901 -p 2222:22 dockerImageName. Docker runs fine. After this i connect to vnc using 0.0.0.0:5901. It connects properly and i get a GUI.

Now i stop the docker using docker stop containerId. Now if i try to rerun the container using command docker start containerId, docker comes up but when i try to connect to vnc using 0.0.0.0:5901, it says connect closed unexpectedly

I am using this image https://hub.docker.com/r/thyrlian/android-sdk-vnc/

Naman
  • 49
  • 6
  • This sounds like something wrong with the image. It isn't handling container stop and start the way you want. You'll need to share your Dockerfile or image if you're looking for more assistance. – King Chung Huang Aug 01 '18 at 16:43
  • i am using this image "https://hub.docker.com/r/thyrlian/android-sdk-vnc/" – Naman Aug 02 '18 at 06:40
  • Thanks @Naman for using the image. The problem is exactly what @King Chung Huang has addressed (please check my comments under his answer). There are actually two lock files should be removed every time when stopping a container. I try to `trap SIGTERM` now and do some clean up work to remove those lock files. The code changes can be viewed [here](https://github.com/thyrlian/AndroidSDK/commit/7678f684eca19af2e122d57f82b0c0e5693737f0). Soon I'll release a new image including this fix. Please try it out. Thanks a lot. – Jing Li Sep 27 '18 at 19:40
  • BTW, ideally, whenever you want to run any test on an Android emulator, you should make sure it's clean state. That's why it's recommended to launch a new container every time, instead of using `docker stop`. Still, I fixed the issue, because I believe you might have some other reason for this case. – Jing Li Sep 27 '18 at 19:41

1 Answers1

1

It looks like the VNC server in the thyrlian/android-sdk-vnc image doesn't start the same way a second time because a lock file gets left behind when the container stops.

If I create and start a container from that image, here's what vncserver-stderr.log shows.

▸ ~ docker run -d -p 5901:5901 -p 2222:22 --name android-sdk-vnc thyrlian/android-sdk-vnc
212b6de3d3ee71f221e7e190baaf650b779cf351a9c4654db19ef3402cdaa86f
▸ ~ docker exec android-sdk-vnc cat /var/log/supervisord/vncserver-stderr.log
xauth:  file /root/.Xauthority does not exist

New 'X' desktop is 212b6de3d3ee:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/212b6de3d3ee:1.log

After stopping and starting the same container, here's what the log shows.

▸ ~ docker stop android-sdk-vnc
android-sdk-vnc
▸ ~ docker start android-sdk-vnc
android-sdk-vnc
▸ ~ docker exec -it android-sdk-vnc cat /var/log/supervisord/vncserver-stderr.log
xauth:  file /root/.Xauthority does not exist

New 'X' desktop is 212b6de3d3ee:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/212b6de3d3ee:1.log


Warning: 212b6de3d3ee:1 is taken because of /tmp/.X1-lock
Remove this file if there is no X server 212b6de3d3ee:1

New 'X' desktop is 212b6de3d3ee:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/212b6de3d3ee:2.log

I'm not familiar with this VNC server, but I'm guessing the lock file at /tmp/.X1-lock is preventing it from running the same way as the first time.

I suggest filing an issue in the source GitHub repository. You can find it on the Docker Hub page for thyrlian/android-sdk-vnc, on the side under Source Repository.

King Chung Huang
  • 5,026
  • 28
  • 24
  • yeah that's the issue. I figured it when i pulled a different docker image with vnc. Thanks – Naman Aug 02 '18 at 18:42
  • 1
    Thanks for your answer. Indeed the issue was caused by the lock file(s). Actually apart from the lock file you've addressed: `/tmp/.X1-lock`, there is another one: `/tmp/.X11-unix/X1`. In order to fix issue, both lock files have to be removed. I have fixed the issue in my code repository, thanks again. – Jing Li Sep 27 '18 at 19:35