/Docker-Custom_Image

Create Docker Custom Image using "Docker commit "command & "Docker build (Dockerfile)" command

Docker-Custom_Image

Create Custom image on Docker:

Screenshot 2024-02-25 181110

Purpose of creating Custom image ?

When requirement is to create container with lot of custom settings. In container world we share images but not share container.

⚡There are two ways to Create Custom image:

1.Docker Commit command

2.Docker Build command (Dockerfile)

🌟 Custom image by Docker commit command 🌟

In this method of creating custom image , 1st we launch conatiner and what we want to changes or add anything that on Conatiner, Then create image from precreated container.

Changes in container (container name -->commitOs1) :--

Screenshot 2024-02-20 180117

Using this "commit" command create custom image-

       #docker commit commitOs1  myos1:v1

Run container from Custom own image(myos1:v1)

       #docker run -it --name mycontainer myos1:v1

Screenshot 2024-02-20 180315

🌟 Custom image by Dockerfile 🌟

This method of creating Custom image use code(YAML), Creating own image by Code is fully Automatic way.

⚡In this process of creating custom image, We put all code in one file that is "Dockerfile"

       #docker build -t myOwnimage:v1 .

⚡& we also put code in custom name file but at Building image time we need to mention File name & path / directory

       #docker build -t myOwnimage:v1 -f myYmlcode /mycodefolder/ 

" -t " --> To Declare name to custom image.

" -f " --> Name of file where code kept.

" . " --> Current directory.

Note:

In code when use interactive command then need to pass argument. example: yum install httpd -y

"FORM" is a keyword in code file to tell about base image.(from base image we create new image)

"RUN" is keyword in code file for running commands.

Use commad to build image from Code(Dockerfile):

       #docker build -t myimage:v1 .

Running container from own custom image(myimage:v1):

       #docker run -it --name myos1 myimage:v1

Screenshot 2024-02-20 185049