Understanding How Docker Containers Work

Getting into Docker can be confusing since they don’t normally behave the same way as we’re used to, working with servers. Here we talk about how containers work in deployment terms.

Facebook
Twitter
LinkedIn

If you primarily have worked deploying to Linux servers, you are most definitely accustomed to deploying incremental changes. Transitioning to Docker you’ll have to adapt that way of thinking.

Docker containers are ephemeral, which means they don’t last very long in deployment terms. In many cases they will be rebuilt from scratch. It’s almost like starting a new server from zero every single time. This is different than servers where you only change what you need to change and that’s it. If, for instance, you want to add a package with apt you’d just run the command and apart from installing  that new package, the server remains mostly untouched.

In Docker that scenario would be completely different. You would actually have to rebuild the container completely to add the package. This is important because by default dynamic information like user uploaded files, environment-specific files, and databases, aren’t persisted. So the next time you deploy a change you may be surprised that information is missing.

Thankfully Docker allows you to persist data by means of a mounted virtual drive. The next time your container is created, the mounted drive will be attached and the data will exist again in the container. Since the drive is mounted to a path, you might have to take that into consideration when integrating it into your application. For more information on persisting data, have a look at Docker’s documentation.

The recommended way is to use volumes.

Never miss another post!

Get my latest articles delivered directly to your inbox.

Never miss another post!

Get my latest articles delivered directly to your inbox.

Upcoming Course

Break Free From Tutorials!

A software development course that doesn’t get you stuck with specifics from a tutorial, but challenges you to think like a software architect. 

🙏

Great Choice!

Thanks for enabling notifications! Don’t worry, I hate spam too and I won’t ever disclose your contact information to 3rd parties.