Original article, welcome to reprint. Reprint please specify: reprint from IT people story, thank you! Create a base Image (14)
This article mainly introduces the relevant information about the specific implementation of Docker Base Image creation, here provides detailed steps, friends who need to refer to github: github.com/limingios/d…
How to make a Base Image
There are two ways of base Image mentioned before: one is to get 1 through pull docker official website; the other is to get 1 through build. It must be done by base Image.
- By pulling
docker pull hello-world
docker image ls
docker run hello-world
Copy the code
- 1. Create a file
mkdir hello-world
cd hello-world/
vim hello.c
Copy the code
2. Edit file C
#include<stdio.h>
int main()
{
printf("Hello Docker wechat official account: Too many programming pits \n");
}
Copy the code
3. Compile GCC
sudo yum install -y gcc
sudo yum install -y glibc-static
gcc -static hello.c -o hello
Copy the code
4. Create and edit Dockerfile
vim Dockfile
Copy the code
FROM scratch
ADD hello /
CMD ["/hello"]
Copy the code
docker build -t liming/hello .
Copy the code
# View the layer
docker history a4cb86cc8d6b
Copy the code
5. Run the Image
docker run liming/hello
docker container ls -a
Copy the code
PS: Hello. C is written in C language, so we type it into an Image, which is actually an executable file. It actually depends on the host kernel, although it is small, it can also reflect the architecture of Docker. Tomcat actually their principle is the same as today’s baseImage hello program.