如何使用vnc在Ubuntu中运行docker image? [英] How to run docker image in ubuntu with vnc?
问题描述
为了检查在docker映像中运行的硒测试,我试图设置一个VNC来验证测试过程中发生的事情。
In order to examine selenium tests running inside a docker image I am trying to set up a VNC to verify what is going on during the tests.
我正在遵循提出的建议此处,并在 Dockerfile
中用以下附加行创建了新的Docker映像:
I am following the suggestions made here and created a new docker image with the following additional lines in Dockerfile
:
RUN apt-get install -y x11vnc
RUN mkdir ~/.vnc
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
然后我使用以下命令启动docker映像:
Then I started the docker image with the following command:
docker run -p 5900 --rm -it --entrypoint /bin/bash selenium-tests
并开始 krdc
作为我的VNC查看器。那么现在怎么办?
and started krdc
as my VNC viewer. So now what?
我在 krdc
中看不到我的docker映像。也许我缺少什么?我是否必须在docker内部显式启动vnc代码?我是否需要将其他参数传递给 docker
命令?
I do not see my docker image in krdc
. Maybe I am missing something? Do I have to start the vnc code inside docker explicitly? Do I need to pass additional arguments to the docker
command?
- docker:1.13 .1
- ubuntu:16.4.03
- krdc:4.14.16
推荐答案
问题中有两个问题使您无法实现想要达到的目标:
There are two issues in the question that prevent you from the goal you want to achieve:
1。图像中缺少X服务器。
1. X server is missed in the image.
2。 VNC服务器应在容器中启动。
2. VNC server should be started in a container.
Dockerfile
的其他部分是:
RUN apt-get install -y x11vnc xvfb
RUN mkdir ~/.vnc
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
其中 entrypoint.sh
是:
#!/bin/bash
x11vnc -forever -usepw -create &
/bin/bash
现在我们可以使用以下命令启动容器:
Now we can start a container using the following command:
docker run --rm -ti -p 5900:5900 <image_name_or_id>
并通过 vncviewer
进行访问启动容器的主机:
and access it via vncviewer
from the same host where container is started:
vncviewer localhost:5900
这篇关于如何使用vnc在Ubuntu中运行docker image?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!