Reputation: 6131
I am starting with the docker and its concepts. I have read official Guide on how to create images, and managed to create several images (proud).
Now I actually wanted to build an MySQL server, so I can connect it with my application. For that purpose, I have found official MySQL Dockerfile.
The thing is, when I run it with:
docker build -t mysql .
It creates two images:
First one has debian as Repository and stretch-slim as a TAG. Size is 55MB
Second has none for both. Size is 65MB.
I am now confused. Why two images? My understanding was it will be one image with Debian and MySQL, but not two.
Some guideline are appreciated.
Upvotes: 0
Views: 253
Reputation: 357
If your Dockerfile has a FROM image, it has a dependency on another image, so It will download and generate all the dependant images.
If you need to create a BASE IMAGE you can do it by using a special image called scratch as a parent image.
i.e:
FROM scratch
ADD hello /
CMD ["/hello"]
For more information about how to create a base image: https://docs.docker.com/develop/develop-images/baseimages/#create-a-simple-parent-image-using-scratch
Upvotes: 1
Reputation: 7085
This is the expected behavior:
As you can read in the first line of the docker-library-bot file from MySQL Dockerfile is says:
FROM debian:stretch-slim
As per Docker documentation:
A Dockerfile must start with a
FROM
instruction. The FROM instruction specifies the Base Image from which you are building.
A base image is an image that has no parent.
So, as a result you will have two images:
Upvotes: 2