Dock
Docker Installation and Basic Commands Using Ubuntu
By Db4Cloud Technologies
Introduction
Containerization has become an essential technology in modern cloud and DevOps environments. Docker allows developers to package applications and dependencies into containers that can run consistently across multiple environments.
In this guide, we will explain how to install Docker on Ubuntu and run basic Docker commands.
Step 1: Update Ubuntu System
Before installing Docker, update the package list.
sudo apt update
sudo apt upgrade -y
This ensures Ubuntu has the latest package versions.
Step 2: Install Required Packages
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
These packages allow Ubuntu to download Docker from secure repositories.
Step 3: Add Docker GPG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
This command adds Docker’s official security key to the system.
Step 4: Add Docker Repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
This adds the official Docker repository.
Step 5: Install Docker
sudo apt update
sudo apt install docker-ce -y
This installs the Docker Community Edition.
Step 6: Check Docker Status
sudo systemctl status docker
If Docker is running correctly, you will see Active (running).
Step 7: Check Docker Version
docker --version
Example output:
Docker version 24.0.6
Step 8: Run Docker Without sudo (Optional)
sudo usermod -aG docker $USER
Then log out and log in again.
This allows running Docker commands without sudo.
Basic Docker Commands
1. Test Docker Installation
docker run hello-world
Docker downloads a test image and runs it.
2. Download an Image
docker pull ubuntu
This downloads the Ubuntu image from Docker Hub.
3. List Docker Images
docker images
Shows all downloaded images.
Recommended by LinkedIn
Example output:
REPOSITORY TAG IMAGE ID
ubuntu latest abc123
nginx latest def456
4. Run Ubuntu Container
docker run -it ubuntu
Explanation:
OptionMeaning-iInteractive-tTerminal
Now you are inside the Ubuntu container.
5. List Running Containers
docker ps
6. List All Containers
docker ps -a
Shows both running and stopped containers.
7. Stop a Container
docker stop container_id
Example:
docker stop 7ab45cd
8. Remove Container
docker rm container_id
Deletes the container.
9. Remove Image
docker rmi image_id
Deletes the Docker image.
Example: Run Nginx Web Server
docker pull nginx
Run the container:
docker run -d -p 8080:80 nginx
Explanation:
OptionMeaning-dRun in background-pPort mapping8080:80Host port → Container port
Now open browser:
You will see the Nginx web server page.
Docker in DevOps at Db4Cloud Technologies
At Db4Cloud Technologies, Docker is used for:
Cloud-native applications
DevOps CI/CD pipelines
Microservices architecture
Kubernetes deployments
Infrastructure automation
Docker helps our engineers deliver scalable, reliable, and automated cloud solutions for global customers.
Conclusion
Docker simplifies application deployment by creating portable containers. With Ubuntu, Docker installation and management become straightforward, making it ideal for developers and DevOps engineers.
Organizations adopting Docker gain faster deployments, consistent environments, and scalable infrastructure.