The following steps can be used for installing any version of Ubuntu on Docker
Eg. Ubuntu 21.04 / 20.10 / 18.04 / 16.04 / 14.04 ...
Introduction
Ubuntu is one of the leading Linux-based operating systems in the world. It is designed for computers, smartphones, and network servers and supports some of the most popular technologies/tools like Nginx, Apache, MySQL, MongoDB, PHP, Python, Redis, etc.
Due to its high ratio of compatibility with trending technologies/tools, it is one of the top choices of OS for setting up web-servers on cloud-platforms such as like AWS, GCS, Azure, DigitalOcean, Linode, etc.
In this guide, I’ll help you install Ubuntu 20.04 on your local Docker instance but the same steps can be used for installing any version of Ubuntu on Docker
There are multiple ways to install Ubuntu on Docker, we are going to see the approach that makes use of the official docker image from Ubuntu team
Before beginning please go through the prerequisites section
Prerequisites
In order to be able to complete this guide please ensure
- That you have successfully installed Docker Engine in your local machine, for Windows users this is included in Docker Desktop application
- Docker Engine or docker service is up and running
- Only for Windows users, please ensure that the container type is Linux Containers and not Windows Containers, if using Windows Container please make use of the menu option and switch to Linux Containers
Without any further ado let’s begin…
Step 1: Go to the docker hub website, this website hosts all the images present in Docker’s official repository
Click Docker Hub to go the website else visit this URL address https://hub.docker.com/
Step 2: Search for the official image of Ubuntu
For your quick reference click Ubuntu Official Docker Image to directly open the official ubuntu docker image page else visit this URL address https://hub.docker.com/_/ubuntu
Step 3: Now look for the version of Ubuntu that you wish to install
Please note that the version of any image on Docker is represented by its TAGS. In our case we wish to install Ubuntu 20.04 so we’ll look for the tag 20.04.
Once you have found the tag run the following command on your local machine
docker pull ubuntu:20.04
20.04 over here represents the tag for the docker image ubuntu. You can replace this tag with any other valid tag being offered by this image.
Once you have run the above command, your local docker engine will download this image from docker’s remote repository and save it locally.
Step 4: Verify if the image has been successfully downloaded in your system or not. Run the following command in your favorite command line tool to see the list of all your locally available images
docker images
On Windows you can also make use of the Docker Desktop application to see all your locally available images
If the image was successfully downloaded then you should see the image details
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 20.04 f63181f19b2f 1 minute ago 72.9MB
If you see the above details then congratulations you just installed Ubuntu 20.04 on Docker.
In the next guide, we’ll see how to setup Ubuntu and how to install LAMP Stack on it.
Hope this guide was helpful to you. Please do drop a feedback so that we can improve this guide further.