🚀 Running an Ubuntu Container with Docker – Hands-On


After understanding Dockerfiles, it’s time to see Docker in action by running a real operating system — Ubuntu — inside a container!
🧰 Prerequisite
Make sure:
Docker is installed and running on your machine (Docker Desktop or CLI)
You have access to a terminal (VS Code, Terminal, or any shell)
🔽 Step 1: Pull the Ubuntu Image
To download the Ubuntu image from Docker Hub, use:
docker pull ubuntu
Also you can head over this link to take a look at the Ubuntu Image page.
This pulls the latest Ubuntu image from the cloud (Docker Hub) and saves it locally.
✅ GUI Check:
If you're using Docker Desktop, navigate to the Images tab, and you’ll now see the ubuntu
image listed.
▶️ Step 2: Run the Ubuntu Image as a Container
docker run -it ubuntu
🔍 Explanation:
docker run
: Starts a new container-it
: Enables interactive terminal modeubuntu
: The name of the image to use
This will drop you inside a terminal running within a Docker container, logged in as root
!
🖥️ Step 3: Try Ubuntu Commands Inside the Container
You now have a full Ubuntu environment inside your container. Test it like this:
root@container-id:~# mkdir hello
root@container-id:~# cd hello
root@container-id:~/hello# touch ubuntu.txt
root@container-id:~/hello# ls
ubuntu.txt
You just:
Created a directory
Navigated into it
Created a file
Verified it exists
✅ Yes, you're running an entire Ubuntu OS inside a Docker container.
💡 Why Is This Cool?
You didn’t install Ubuntu separately.
It runs isolated from your main system.
You can experiment, break, and restart it without affecting your host machine.
🧠 Summary:
Pulled a base image (
ubuntu
) from Docker HubStarted a container with interactive access
Ran typical Linux commands inside it
Verified the container from the Docker GUI
In next blog we will explore how do you create your own docker image with the snap of your finger.
Subscribe to my newsletter
Read articles from Sumit Mukharjee directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
