In this tutorial, we are going to install and setup docker on an Ubuntu server.
Update and Prepare the System
Install Dependencies
Let's first install the necessary dependencies. Use the following commands.
bash
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common -yAdd Docker’s GPG Key
bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgThis indicates that the software we are installing is authentic.
Add the Docker Repository
bash
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/nullThis will use the latest version of Docker.
Installing Docker
bash
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io -yVerify the Docker installation
Check the Docker status using the following command.
bash
sudo systemctl status dockerIf everything is good, it will show as below.
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)
Active: active (running) since Fri 2026-05-01 04:08:44 UTC; 1 day 8h ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 73211 (dockerd)
Tasks: 41
Memory: 234.1M (peak: 249.4M)
CPU: 56.968sDocker container testing
To run the test, run the Hello World container
bash
sudo docker run hello-worldOutput:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4f55086f7dd0: Pull complete
Digest: sha256:f9078146db2e05e794366b1bfe584a14ea6317f44027d10ef7dad65279026885
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.Docker Commands
Let's look into the example of running container:

np@np:~$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
oracle/database 19.3.0-ee dd6c130762a3 11 days ago 6.54GB| Command | Description |
|---|---|
docker ps -a | List all the running containers |
docker images | List all the images |
docker stop <container_id> | Stop the running container with the container ID e.g docker stop 767c0a92e087 |
docker rm <container_id> | Remove the container e.g: docker rm 767c0a92e087 |
docker rm -f <container_id> | To force to remove the running container in one command |
docker container prune | To remove all the stopped containers(not recommended) |
docker stop $(docker ps -aq) | To stop all the containers(not recommended) |
docker rm $(docker ps -aq) | Remove all the docker containers permanently |
docker rmi <image_id> | To delete the specific image |
docker rmi -f <image_id> | To remove the docker image forcefully |
docker image prune | To remove unused images(not recommended) |
docker rmi -f $(docker images -aq) | Remove all the images(Not recommended) |
Note: the deleted images need to be re-downloaded if we need it later
Now we do have a fully functional Docker environment with Docker commands. Now we can use it to manage pulling Docker images, for e.g mysql, our own app images etc.
