Advertisement
linuxserver Docker is one of the most powerful tools in modern DevOps and software development. It lets you run apps in isolated containers so everything works the same on every machine — no more “it works on my laptop!” problems.

Using Docker on Linux: A Complete Beginner’s Guide (Step-by-Step Tutorial)

5 Min Read Verified Content

🚀 What Is Docker (Explained Like You’re Five)

Imagine you want to run an application, but it needs:

  • a specific version of Python

  • a certain Linux library

  • a particular config file

Instead of installing all that manually, Docker packs everything into a container that works anywhere.

Think of it like a portable mini-computer with everything the app needs.

No conflicts.
No errors.
No dependency headaches.




🛠️ Step 1: Install Docker on Linux

Works for Ubuntu, Debian, Linux Mint

Run these commands:

sudo apt update sudo apt install ca-certificates curl gnupg -y

Add Docker’s GPG key:

sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo tee /etc/apt/keyrings/docker.asc > /dev/null sudo chmod a+r /etc/apt/keyrings/docker.asc

Add the Docker repository:

echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \ https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker:

sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io -y

Check if Docker works:

sudo docker --version

You should see something like:
Docker version 26.x.x




🧰 Step 2: Allow Running Docker Without sudo

Typing sudo every time is annoying.

Add your user to the docker group:

sudo usermod -aG docker $USER

Then log out and log back in.

Test without sudo:

docker ps

If no error → you’re good!




🐳 Step 3: Pulling Your First Docker Image

Docker images are like app templates.
Docker containers are running apps from those templates.

Pull an image:

docker pull ubuntu

List your images:

docker images

Run a container:

docker run -it ubuntu bash

Inside the container → try commands:

ls pwd whoami

Exit:

exit

Boom! You just ran Linux inside Linux.
Welcome to the matrix.




📦 Step 4: Running Containers in the Background

Let’s run Nginx (a web server):

docker run -d -p 8080:80 nginx
  • -d = detached mode (background)

  • -p 8080:80 = map port 8080 to the container’s port 80

Visit in browser:

http://localhost:8080

You’ll see the Nginx welcome page.

Check running containers:

docker ps

Stop the container:

docker stop <container-id>


🔁 Step 5: Restarting and Removing Containers

See all containers (including stopped ones):

docker ps -a

Start a stopped container:

docker start <id>

Remove a container:

docker rm <id>

Remove the image powering it:

docker rmi nginx


🧱 Step 6: Building Your Own Docker Image

Create a file named Dockerfile:

FROM ubuntu:latest RUN apt update && apt install -y curl CMD ["bash"]

Build it:

docker build -t my-ubuntu .

Run it:

docker run -it my-ubuntu

Congrats!
You created your own container image — like a mini OS you built yourself.




📁 Step 7: Docker Volumes (Saving Data the Right Way)

Containers are temporary.
If they die, your data dies too.

Use volumes to save data:

docker run -d -p 3306:3306 \ -v mysql_data:/var/lib/mysql \ --name mysql \ -e MYSQL_ROOT_PASSWORD=12345 \ mysql

Now your MySQL data survives container restarts.

Check volumes:

docker volume ls


🔗 Step 8: Docker Compose (Super Useful for Beginners)

Docker Compose lets you run multiple containers with one command.

Create docker-compose.yml:

services: app: image: nginx ports: - "8080:80"

Run it:

docker compose up -d

Stop:

docker compose down

Easy and powerful.




💡 Practical Real-World Things You Can Do With Docker

  • Run WordPress easily

  • Test PHP, Python, Node.js apps

  • Host a MySQL or PostgreSQL database

  • Deploy apps faster

  • Set up dev environments instantly

  • Learn Linux safely inside containers

  • Run everything isolated and clean




📌 Conclusion

Docker may look scary at first, but once you understand images, containers, volumes, and commands like run, pull, build, and compose, everything becomes easy and fun. This guide gave you the clearest beginner-friendly explanation possible, with step-by-step actions perfect for newbies, students, or developers starting DevOps for the first time.

Advertisement
Back to Linuxserver