This is the step-by-step process I took to create the Docker image.

Create a directory just to save the file:

$ mkdir ~/Docker
$ cd ~/Docker

Install Docker case you don’t have it yet and give permission to your user:

$ sudo apt  install docker.io
$ sudo usermod -aG docker ${USER}

Log out and log in again to get into this docker group, or alternatively:

$ su ${USER}

Create the Dockerfile with the instructions to install the needed files:

$ vi Dockerfile
# Ubuntu as parent file
FROM ubuntu

# Update the image to the latest packages
RUN apt-get update && apt-get upgrade -y

# Install needed tools
RUN apt-get install automake bison build-essential flex gcc-arm-none-eabi gperf git libncurses5-dev libtool libusb-dev libusb-1.0.0-dev pkg-config kconfig-frontends genromfs zlib1g-dev -y

# Create how nuttxspace
WORKDIR /nuttxspace

#clone needed files:
RUN git clone https://github.com/apache/nuttx /nuttxspace/nuttx
RUN git clone https://github.com/apache/nuttx-apps /nuttxspace/apps

Built it:

$ docker build .

Verify if it was created correctly:

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
<none>       <none>    f0a673f5538d   About a minute ago   3.9GB
ubuntu       latest    6b7dfa7e8fdb   6 weeks ago          77.8MB

Tag the image:

$ docker tag f0a673f5538d acassis/ubuntu-nuttx

Run the image:

$ docker run -it acassis/ubuntu-nuttx /bin/bash

If everything worked fine, you could wish to submit it to Docker hub

So, re-tag the image with a version number to submit:

$ docker tag acassis/ubuntu-nuttx acassis/ubuntu-nuttx:v1

Login in the docker:

$ docker login

Send the docker image:

$ docker push acassis/ubuntu-nuttx:v1

Everything done!

If for some reason you want to remove your local image:

$ docker rmi -f f0a673f5538d