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.
- Installing Docker
- Pulling the Image
- Creating the Container
- Running the Container
- Stopping or Killing the Container
- Updating the Container
- Editing in the Container
- Helper Command Reference
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.
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.
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
.
- Clone the repository. GitHub CLI or Git, both are great!
- Change directory into the appropriate path.
- 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.
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.
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.
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
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.
With the help of VSCode's Remote - Containers extension, you can edit files in the Docker container.
- Just install the above extension in your VSCode application.
- After starting the container, you can open the command pallette (with Ctrl-Shift-P (or Cmd-Shift-P on Mac))
- Search for Remote-Containers: Attach to Running Container and select the appropriate container.
- 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.
/root/login
: This just changes the current user toubuntu
and move you to/home/ubuntu
/home/ubuntu/install_dev_tools
: This just installs some useful tools likenvim
andvim
. 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 littleapt update; apt upgrade
wrapper.rossource
: This command can only be called whenubuntu
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
- 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