How to Install Docker on Linux and Run Your First Container

Absolutely!

The containers themselves are ephemeral. Every time you start up that container, either with the docker run command or from a Dockerfile and the line FROM, you get the exact same result each time. The closest analogy would be like a base image for a VM.

So, if I wanted a basic web server like Apache, I can do docker run httpd or I can put FROM httpd in a Dockerfile, and I can be guaranteed that, on any machine using Docker, I get the same image. So backing up the container itself just isn’t necessary.

Your configs and your data are not ephemeral. They need to persist across container instances and across container hosts:

  • Configs: Any file that alters the behavior of the container instance. Examples would be your Dockerfile, the httpd.conf file for a web server, the www.conf file for a php-cgi/php-fpm container, etc.
  • Data: Your code you need the application inside the container instance to run, the database and its tables (maybe a .sqlite file or maybe a volume that stores all of Postgres’ or MariaDB’s files)

You mount (read attach) your configs and data to the container instance, that way they persist. And anything you would mount or attach becomes your backup material.

I’m probably over-simplifying some terminology, so someone with more technical knowledge about containers can correct me on the definitions, but hopefully this makes some sense!

2 Likes