Member-only story
Docker for absolute beginners: the difference between an image and a container
Learn the difference between Docker images and containers + practical code examples
Containers, images, environments, building, running, virtual machines.. when you’re new to Docker all of these abstract terms can be a bit confusing. In this article we’ll go through all of them and get an understanding of each term. We’ll focus on explaining the difference between images and containers and how they work together, but along the way we’ll explore other Docker-related things. At the end of this article you’ll:
- understand how to build an image
- understand how to spin up an image
- understand the difference between an image and a container
- understand how to user Docker better in your day-to-day work
Let’s code!
Docker in a nutshell
Docker is the answer to ‘but it worked on my machine!’ Imagine that you’ve written a small program on your laptop: let’s say that it’s a simple Python API. Now you want to deploy this program on a laptop of a coworker or on a server. You copy the code, spin up the API and it crashes. Why?