DEV Community

Cover image for What Is Docker and Why Developers Love It
Lorenzo Fazioli
Lorenzo Fazioli

Posted on Originally published at snorty.space

What Is Docker and Why Developers Love It

What Is Docker and Why Developers Love It

Docker is an open-source platform that packages applications and their dependencies into lightweight containers. Containers make software portable, consistent, and easy to deploy across different environments.


What Is a Container?

A container includes everything an application needs to run:

  • Source code
  • Libraries
  • Runtime
  • Configuration
  • Dependencies

Unlike virtual machines, containers share the host operating system, making them significantly faster and more efficient.


Containers vs Virtual Machines

Docker Containers Virtual Machines
Lightweight Heavy
Fast startup Slower startup
Share host kernel Full guest OS
Lower resource usage Higher resource usage

Installing Docker

Ubuntu:

sudo apt install docker.io
Enter fullscreen mode Exit fullscreen mode

Start Docker:

sudo systemctl start docker
Enter fullscreen mode Exit fullscreen mode

Enable Docker at boot:

sudo systemctl enable docker
Enter fullscreen mode Exit fullscreen mode

Run Your First Container

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

If Docker is correctly installed, you'll see a welcome message.


Useful Docker Commands

List running containers:

docker ps
Enter fullscreen mode Exit fullscreen mode

List all containers:

docker ps -a
Enter fullscreen mode Exit fullscreen mode

List downloaded images:

docker images
Enter fullscreen mode Exit fullscreen mode

Stop a container:

docker stop <container_id>
Enter fullscreen mode Exit fullscreen mode

Remove a container:

docker rm <container_id>
Enter fullscreen mode Exit fullscreen mode

Docker Hub

Docker Hub is the official repository for container images.

Thousands of ready-to-use images are available, including:

  • Ubuntu
  • Nginx
  • MySQL
  • PostgreSQL
  • Redis
  • WordPress

Security Best Practices

When using Docker:

  • Use official images.
  • Keep images updated.
  • Avoid running containers as root.
  • Scan images for vulnerabilities.
  • Remove unused containers and images.

Conclusion

Docker has transformed modern software development by making applications portable and easy to deploy. Whether you're a developer, system administrator, or cybersecurity professional, learning Docker is a valuable investment.


Originally published by Lorenzo Fazioli at Snorty.

Top comments (0)