Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to build your own Docker image

Shulou Source: shulou.com Published: 2022-06-02 07:47:48 10月27日 Update

This article introduces the knowledge of "how to build your own Docker image". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Command: docker container commit: Create a new image from a container's changes

The above command can be simplified as: docker commit

That is, first create a container based on a certain image, and then make some changes in the container, such as installing some software

Command: docker image build can be simplified to docker build

Re-commit the container into an image:

Docker commit (container name that has been exited) (the name of the image you want to generate)

So what's the difference between the newly generated image and the original image?

1. It is 2. 5% bigger than the original one. Their history is the same, but the new image is one more layer than the original, and this layer is some software you installed.

The way to create an image above is not very recommended, because other people will not know how the image is generated when they see this image. It is very likely that there are some unsafe things in this image.

Generally use Dockerfile to create image:

Go to Build an image via Dockerfile

Install vim on the basis of centos

Need to add FROM centos to Dockerfile

Add RUN yum install-y vim (this image is read-only, how do we write to it?)

Docker build-t (name).

Tags: Commands names images things content that is more knowledge software practicality security exactly the same successful learning and then representatives history dilemma foundation reality situation. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Shulou Tech Info Apple Microsoft