DEV Community

Cover image for Docker Basics: Getting Started with Containers
chandra penugonda
chandra penugonda

Posted on

Docker Basics: Getting Started with Containers

What is Docker?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.

Installing Docker sets up Docker Engine (background daemon managing containers like VMs) and CLI (interacts via API; other tools use it too).

Running Your First Container

Echo test:
docker run busybox echo "hello world"
Enter fullscreen mode Exit fullscreen mode
  • docker run: Starts container from image.
  • busybox: Minimal Linux image; echo outputs message. Pulls if absent; runs once, exits.

Interactive:

docker run -it busybox
Enter fullscreen mode Exit fullscreen mode
  • -it: -i (stdin connect) + -t (pseudo-terminal).
  • Shell access; exit stops/removes.

Packages count:

dpkg -l | wc -l
Enter fullscreen mode Exit fullscreen mode
  • dpkg -l: Lists Debian packages.
  • | wc -l: Counts lines (minimal: <100).

Dive Deeper: Ubuntu Container with figlet

Launch:

docker run -it ubuntu
Enter fullscreen mode Exit fullscreen mode
  • Pulls Ubuntu image.
  • -it: Interactive root shell (bare-bones system).

Install:

apt-get update
apt-get install figlet

Enter fullscreen mode Exit fullscreen mode
  • update: Refreshes repos.
  • install: Adds figlet (ASCII art); root skips sudo.

Test:

figlet hello
Enter fullscreen mode Exit fullscreen mode
  • Prints "HELLO" art; install if missing—shows isolation.

Key Takeaways

Containers isolate/reproduce envs. Start with docker run. Experiment, exit to clean. Next: Images/volumes.

Top comments (0)