HiBlog Linux and Windows Server

What Is Docker? Images, Containers, and Volumes Explained

  • Ali GhanimatiAuthor
  • Last updated
  • 2 minutesReading time
  • 251Views
  • Ali Ghanimati
  • Last updated:
  • 2 min read
  • 251 views
What Is Docker? Images, Containers, and Volumes Explained

Docker lets you package an application and its dependencies into an image and run it as a container. A developer and a test server can run the same image without installing each dependency manually. A container shares a kernel with its host environment while keeping its process and filesystem views separate.

Begin by distinguishing what you build, what you run, and what should survive when a container is deleted. This makes the difference between replacing an application and losing its data.

Images, containers, and volumes

An image provides the files and startup settings. A container is a running or stopped instance of an image with its own writable layer. A volume provides storage separate from that layer. Use volumes for data that outlives a container, and plan backups separately. Docker container basics and Docker volumes.

Two application containers running on a shared Docker Engine and host operating system

Run a local web server

With Docker running and port 8080 available, execute:

docker run --rm -p 127.0.0.1:8080:80 nginx

Open http://localhost:8080. Docker maps the computer’s local port 8080 to port 80 inside the container. Stop it with Ctrl+C. The --rm option removes the container after it exits.

Keep data across replacements

The disposable Nginx example needs no persistent data. For an application that writes to disk, mount a volume in the directory it uses and reattach that volume to later containers. Test backup and restore, and confirm what happens when removing volumes. How web servers handle requests.

Share Post

hidata.org/en/blog/what-is-docker/
In Social Media

Add Comment

Related Articles