Dockerfile for Jderobot

1 minute read


  • Build a Dockerfile to run my experiments.
  • Follow good practices for Docker.
  • Test Dockerfile.


Docker is a platform for developers which make applications easy to share and deploy. Using Docker containers are self-sufficient and can be run in natively on Linux, Moreover, containers are lightweight compared with virtual machines since containers share the kernel of the host machine, unlike virtual machines that brings its own operating system [3].

Figure from Docker Docs


These are some parts of the Dockerfile that I will be using for now, it is going to be updated as the projects is developed. Some good practices that I followed from [2] [1] reducing the number of layers (represent docker instructions) by lowering the number of instructions that create layers like RUN, COPY and ADD.

# ROS melodic
RUN sh -c 'echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' && \
    apt-key adv --keyserver 'hkp://' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 && \
    apt update && apt install -y --no-install-recommends \

# Jderobot base and assets
RUN sh -c 'echo "deb [arch=amd64] `lsb_release -cs` main" > /etc/apt/sources.list.d/jderobot.list' && \
    apt-key adv --keyserver --recv 24E521A4 && \
    apt update && apt install -y --no-install-recommends \
        jderobot \
        jderobot-assets \
        ros-melodic-jderobot-assets && \
    echo "source /opt/jderobot/share/jderobot/gazebo/" >> ~/.bashrc && \
    echo "source /opt/jderobot/share/jderobot/gazebo/" >> ~/.bashrc && \
    echo "source /opt/jderobot/setup.bash" >> ~/.bashrc && \
    source ~/.bashrc

Also Sorting multi-line arguments helps to easily manage your packages.

RUN apt-get update -y && apt-get -y upgrade && apt-get install -y --no-install-recommends \
        apt-utils \
        cmake \
        curl \
        firefox \
        git \
        icewm \
        python-opengl \
        python3-setuptools \
        python3-pip \
        sudo \ 
        tmux \
        vim \
        wget \
        xvfb \
        x11vnc && \
    pip3 install jupyterlab virtualenv && \
    apt-get autoclean && \
    apt-get autoremove

The full Dockerfile that I will be using can be found here.


For building a Dockerfile

docker build -t example .


[1] Dev Community, Improve your Dockerfile, best practices

[2] Docker Docs, Best practices for writing Dockerfiles

[3] Docker Docs, Getting started