Docker Images
- Docker images are required to create containers.
- From one Docker image, we can create multiple containers
- Images are build-time constructs and containers are run-time constructs.
- Let pull some images and observe the stuff as shown below
- Docker image is collection of Image Layers
- When we build the image we use some base image and on top of this we do add some stuff related to our applications. Let me write a simple Dockerfile and create a image from this
FROM debian
RUN apt update
* Now lets inspect the debian image docker image inspect debian
and test image docker image inspect test:1.0
* The test:1.0 uses the layer from debian and adds a new layer this new layer is created as the result of the RUN statement (RUN apt update).
* Now lets build a new docker image test:2.0
with the following Dockerfile and inspect the image
FROM debian
RUN apt update
CMD ["echo", "helloworld"]
* Lets inspect test:2.0
* Lets update the Docker file and build the docker image test:3.0
FROM debian
RUN apt update
ADD test.txt /
CMD ["echo", "helloworld"]
* As we have observed so far, whenever we make changes that leads to some changes in the file system (RUN, ADD) a new layer is getting created
* Creating too many layers is not considered as good practice so you would often see Docker files with long RUN statements RUN statement1 && statement2
* The Layers get shared across images
* We would write Dockerfiles for our applications and create the docker images.
Docker image Registry
- We can store Docker images centrally in image Registries
- The Default Registries is DockerHub.
- There are many other Registries to Store docker images
- Cloud Registries:
- Azure Container Registry
- AWS ECR
- Docker Hub (Public and Private)
- And many other
- Hosted Registries
- Artifactory/Jfrog
- We can also use Docker Registry Image to store our images