Skip to content

Quick and neat Docker image with ROS full desktop.

Notifications You must be signed in to change notification settings

embedml/docker-ros-desktop-vnc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ROS Noetic - VNC-enabled Docker container

Docker container featuring a full ROS Noetic Ubuntu Focal installation. Heavily based on bpinaya's project. Read the README of the repository this is a fork of for more information. This rest of this README will consist of information on how to setup this docker container.

Table of Contents

  1. Installing Docker
  2. Pulling the Image
  3. Creating the Container
  4. Running the Container
  5. Stopping or Killing the Container
  6. Updating the Container
  7. Editing in the Container
  8. Helper Command Reference

Installing Docker

There is no way I could possibly explain how to install Docker any better than the official documentation itself so here ya go.

Note that below I will be ommitting the usage of sudo as a prefix for the docker command. In some cases, using sudo docker may be necessary.

Pulling the Image

I suggest users pull from Docker Hub instead of building the image themselves. The former tends to take less time, especially if you have fast internet speeds.

From Docker Hub

This image can now be found on DockerHub here. To pull this image, do

$ docker pull arvinskushwaha/ros-noetic-desktop-vnc

In further instructions, when <tag-name> is mentioned, use arvinskushwaha/ros-noetic-desktop-vnc.

From GitHub

  1. Clone the repository. GitHub CLI or Git, both are great!
  2. Change directory into the appropriate path.
  3. Build the docker image.
$ docker build -t <tag-name> . # The <tag-name> is completely up to you.

This command will take time. Update, upgrading, and installing ros-noetic-desktop-vnc takes approximately 30 minutes. The rest of it is rather fast.

Creating the Container

To create a container from this image, we use the docker run command. This command is highly configurable, so choose whatever helps your workflow the best! Here, <tag-name> is either the Docker Hub image name (arvinskushwaha/ros-noetic-desktop-vnc) or whatever you chose above

Warning! Once you pick a configuration for a container, you're stuck with it. Choose wisely!

$ docker run [-p <host-novnc-port>:80] \ # Port 80 is where NoVNC can be accessed from
	[-p <host-vnc-port>:5900] \ # Port 5900 is where VNC can be accessed from
	[--name <cotainer-name>] \ # However you want to reference the container in the future
	-d # Runs the container in detached mode (so it has persistent state)
	 <tag-name>

I personally suggest -p 6080:80 and -p 5900:5900 as the host-container port combinations for NoVNC and VNC, respectively. To then access NoVNC, pull up http://localhost:<host-no-vnc>. Otherwise, for VNC, install a VNC client and use localhost:<host-vnc-port> as the address.

Running the Container

Check if the docker container is running using docker ps -a. If the docker container in question is not running. Start it using docker start <container-name>. If you chose not to name the container, use docker start <container-id>. This ID should be given in the third(?) column of docker ps -a.

Now, we can enter the "terminal" (or use VNC is preferred). To do this, just execute the following command:

$ docker exec -it <container-name> bash
root@numbers69420:/root# ./login  # This here is a nice convenience script that I've written for no real reason :)
ubuntu@id42064:~$ # tada now you're logged in as ubuntu and at /home/ubuntu
# ...
# to exit
ubuntu@id42064:~$ exit
root@numbers69420:/root# exit

Again, replace <container-name> here with the id if needed. Also, see helper command reference.

Stopping or Killing the Container

If the container is unresponsive or you're done with using the container and want to shut it down, use the following command:

$ docker stop <container-name> # if shutting down nicely
$ docker kill <container-name> # or forcefully

Updating the container

If a brand-new, sparkly docker image comes out, and you wish to update, unfortunately, my current understanding is that you would have to delete the previous container and user the new image to create a new container. Of course, that's rather dismal, so the docker cp command may come in handy. Essentially, it just lets you copy data from docker to your host.

$ docker cp <src-path> <dest-path>

I believe <src-path> and <dest-path> must be such that one is on the host and one is in the container. They are given as follows:

  • For a path on the host, it is simply given as usual: </path/to/file>. It must be an absolute path and may be either a file or a directory
  • For a path in the container, it is given as <container-name>:</path/to/file>. Similarly, this must be an absolute path and can be either a file or a directory.

See the docs for more (and better) info.

Editing in the Container

With the help of VSCode's Remote - Containers extension, you can edit files in the Docker container.

  1. Just install the above extension in your VSCode application.
  2. After starting the container, you can open the command pallette (with Ctrl-Shift-P (or Cmd-Shift-P on Mac))
  3. Search for Remote-Containers: Attach to Running Container and select the appropriate container.
  4. In the new window, use as normal. You may have to reinstall some of your extensions.

NOTE: For this to work, the docker command must not require sudo. See here for more info. Furthermore, the VSCode instance will instantiate using root. I recommend switching to user ubuntu for more effective use.

Helper Command Reference

  • /root/login: This just changes the current user to ubuntu and move you to /home/ubuntu
  • /home/ubuntu/install_dev_tools: This just installs some useful tools like nvim and vim. This is run already when the image was built, so you don't really need to call it, except to update neovim and vim.
  • /home/ubuntu/upgrade: This just goes ahead and upgrades all packages on the system. It's a nice little apt update; apt upgrade wrapper.
  • rossource: This command can only be called when ubuntu is the current user. It sources the $ROS_WS/devel/setup.bash file, which by default is located at /home/ubuntu/ros_ws/devel/setup.bash

Acknowledgements

  • This image is based on FCWU image, that has the support for the VNC server with browser support, so no VNC client is needed, kudos to them!
  • A significant portion of this docker container and README is based off of fbottarel's repo and bpinaya's repo

About

Quick and neat Docker image with ROS full desktop.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 87.2%
  • Dockerfile 12.8%