Cloud Native 7 min read

How to Build a Reusable Docker‑Based Development Environment on Ubuntu 20.04

This guide explains how to create a repeatable development environment by installing Docker on Ubuntu 20.04, building a template container with common front‑end tools, committing and tagging the image, and optionally using VirtualBox for GUI‑based workflows.

21CTO
21CTO
21CTO
How to Build a Reusable Docker‑Based Development Environment on Ubuntu 20.04

Install Docker

First, install Docker on an Ubuntu 20.04 instance by installing prerequisites, adding Docker’s GPG key and repository, updating apt, and installing the Docker Engine.

sudo apt-get install ca-certificates curl gnupg lsb-release -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
sudo usermod -aG docker $USER

Log out and log back in for the group change to take effect.

Create a “template” container

Run an Ubuntu container that will serve as the base image:

docker run -ti --name=ubuntu-dev-base ubuntu:latest

Inside the container you are at a bash prompt.

Install “base” software

Update the package index and install common front‑end development tools:

apt-get update
apt-get install nodejs npm -y
npm install -g sass
apt-get install git -y

After installing any additional CLI tools, exit the container:

exit

Commit and tag the template image

Commit the container’s state to a new image and tag it for reuse:

docker commit ubuntu-dev-base
docker tag <IMAGE_ID> ubuntu-dev-base

Replace IMAGE_ID with the ID shown by docker images.

Launch new development containers

Start a fresh container from the template and attach a shell:

docker run -it -d --name ubuntu-projectX ubuntu-dev-base
docker exec -it ubuntu-projectX bash

You can create as many identical environments as needed, knowing the original template remains unchanged.

Handling GUI tools

If a graphical development environment is required, use a virtual machine such as VirtualBox. Create a VM, install the needed GUI applications, then clone the VM for future reuse.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerDevelopment EnvironmentUbuntuVirtualBoxcontainer template
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.