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.
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 $USERLog 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:latestInside 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 -yAfter installing any additional CLI tools, exit the container:
exitCommit 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-baseReplace 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 bashYou 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
