Denny Lim
Trying Ubuntu doesn't have to mean installing it on your system or setting up a virtual machine. With Docker, you can run Ubuntu locally in an isolated container environment in just a few minutes. This guide is designed for beginners who want to explore Ubuntu using Docker without modifying their system.
To make sure Docker is installed correctly, open your terminal or command prompt and run:
docker --version
You should see something like:
Docker version 24.0.2, build cb74dfc
If you get an error, make sure Docker Desktop is running.
Docker images are pre-built templates used to create containers. To download the latest Ubuntu image, run:
docker pull ubuntu
This command fetches the official Ubuntu image from Docker Hub.
Now let’s run a container from the Ubuntu image:
docker run -it ubuntu
Here’s what the options mean:
-it
: Runs the container in interactive mode with a terminalubuntu
: The image to useYou’ll now be inside a shell running inside the Ubuntu container. Try typing:
ls
You’re in Ubuntu!
Ubuntu containers are minimal by default. To install common utilities, use:
apt update apt install nano curl iputils-ping -y
This gives you a simple text editor (nano
), a downloader (curl
), and the ping
command.
To leave the Ubuntu shell, type:
exit
The container will stop when you exit unless you run it with special flags (like --rm=false
or --detach
).
To see stopped containers:
docker ps -a
To restart a container by its ID:
docker start -ai <container_id>
To remove it:
docker rm <container_id>
If you want your container to persist (so you can keep files or install packages long-term):
docker run -it --name myubuntu ubuntu
This names your container myubuntu
, so you can start it later with:
docker start -ai myubuntu
That’s it! You’ve now learned how to run Ubuntu locally using Docker. It’s a safe and fast way to explore Linux, try out commands, or test software—without altering your main operating system.
For more tips, check out:
Happy experimenting!