3. Docker Image
When working with Docker, you may often encounter the terms “image” and “container” used interchangeably, but there are distinct differences between them.
A Docker image is similar to a food recipe that contains meticulous instructions and steps for running an application. On the other hand, a Docker container is like a prepared dish that brings the recipe to life — a fully functional instance.
While a single image can have multiple running instances as containers, these containers operate independently of each other and remain unaware of one another’s existence.
For personal projects, you typically build your own images. However, for many tasks, there are already many pre-built images available from the community.
For instance, Docker Hub is the largest registry hosting over a million images, all a couple of terminal commands’ away, once you have Docker installed on your machine.
This registry includes official images for various operating systems (Ubuntu, CentOS, Debian), software stacks and programming languages (Node.js, Python, MySQL, Nginx), databases, pre-packaged and pre-configured ML frameworks (TensorFlow, PyTorch with GPU support, Sklearn), and much more.
To illustrate, let’s say you want to download the official release candidate for Python 3.12 and start using it on your machine. You can accomplish this with just two simple commands:
$ docker pull python:3.12-rc-bullseye
$ docker run -it python:3.12-rc-bullseye
The second command with the
-it flag will initiate an interactive terminal within a container created from the
python:3.12-rc-bullseye image. This running container instance will resemble a mini-operating system solely equipped with Python 3.12, with nothing else installed.
However, like any Ubuntu distribution, you can install additional tools like Git or Conda within the container and perform almost any task you would typically do in Ubuntu, although without a graphical user interface (GUI).