Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Build your own Docker image

Shulou Source: shulou.com Published: 2022-06-03 05:54:34 11月12日 Update

Container to Image (not recommended)

Create a container with centos image, modify the contents of the container

docker image ls

docker run -it centos

yum install -y vim

exit

If you want to understand the learning route of big data, want to learn big data knowledge and need free learning materials, you can add group: 784789432. Welcome to join. Every day at 3 p.m. live broadcast to share basic knowledge, at 20:00 p.m. live broadcast to share big data project actual combat.

Looking at the container and converting it to an Image, I noticed that it was slightly larger than the native centos. Create new image name liming/centos-vim

docker container ls -a

docker commit

docker commit container name liming/centos-vim

docker image ls

Look at the layer relationship of the new image. The newly created image is actually adding a layer above the centos layer.

docker history Container ID

Container ID of docker history centos

The above method of publishing an Image is actually not recommended and unsafe, because of the possibility of publishing an unstable Image.

Docker build means Dockfile (recommended)

Delete images and containers created earlier

docker image rm liming/centos-vim

docker image ls

docker container ls

docker container ls -a

docker container rm c5a14ab5c071

docker container ls -a

docker container ls

Creating Dockerfile

mkdir docker-centos-vim

cd docker-centos-vim/

vim Dockerfile

Edit Dockerfile

FROM centos

RUN yum install -y vim

Dockerfile build

docker build -t liming/centos-vim-new .

PS: Why do you recommend Dockerfile, because files can be edited at will, if you use containers, how can you send trouble to others? It's still convenient for a single file.

past exciting

Tags: Container method learning recommendation above name data file knowledge live broadcast wonderful security that is content possibility basics basics large numbers learning materials actual combat Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Huawei MySQL Shulou Tech Info vpn