diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9429cc7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM ubuntu:18.04 + +RUN apt update && \ + apt install -y \ + gnupg2 \ + openssl \ + curl \ + net-tools \ + xvfb \ + x11vnc \ + novnc \ + fluxbox \ + && apt clean + +RUN curl -sSL http://get.gazebosim.org | sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..fffd015 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Example docker using novnc for graphical output + +## How to run +1. Open the docker container. If the docker image isn't built, it will build it for you. +``` +./run +``` + +2. Once inside the running container, load the vnc server with the following command: +``` +./novnc +``` + +3. Run Gazebo in the container to get some graphics output: +``` +gazebo +``` + +4. Open your web browser to the following URL: `http://localhost:6080/vnc.html` and press the connect button (no password needed). You should see the gazebo window. diff --git a/novnc b/novnc new file mode 100755 index 0000000..87d37e6 --- /dev/null +++ b/novnc @@ -0,0 +1,21 @@ +# Run the virtual framebuffer: +Xvfb $DISPLAY -screen 0 1024x768x16 & +#sleep 1 + +# Run the minimalistic window manager: +fluxbox & +#sleep 1 + +# Run the vnc server: +x11vnc -display $DISPLAY -bg -forever -nopw -quiet -listen localhost -xkb & +#sleep 1 + +# Run the web novnc server: +websockify -D --web=/usr/share/novnc/ 6080 localhost:5900 & + +echo +echo "******************************************************" +echo "In the browser go to: http://localhost:6080/vnc.html" +echo "and connect with no password" +echo "******************************************************" +echo diff --git a/run b/run new file mode 100755 index 0000000..24ddd2d --- /dev/null +++ b/run @@ -0,0 +1,27 @@ +#! /bin/bash + +DOCKER_IMAGE=graphics_docker +CONTAINER_NAME=test-graphics-docker + +echo "Checking if $DOCKER_IMAGE docker image exists..." +if [[ "$(docker images -q $DOCKER_IMAGE 2> /dev/null)" == "" ]]; then + echo "Image does not exist. Building it..." + docker build -t $DOCKER_IMAGE . +else + echo "Image exists." +fi + +if [[ $(docker start $CONTAINER_NAME 2> /dev/null) ]]; then + echo "$CONTAINER_NAME docker container exist. Connecting to the environment..." + docker exec -it $CONTAINER_NAME /bin/bash +else + echo "$CONTAINER_NAME container doesn't exist. Starting the environment..." + docker run -it \ + --name $CONTAINER_NAME \ + -v $(pwd):/test \ + --env DISPLAY=:0 \ + -p 6080:6080 \ + -w /test \ + $DOCKER_IMAGE \ + /bin/bash +fi