Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make your own docker image

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to make your own docker image". In daily operation, I believe many people have doubts about how to make their own docker image. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the question of "how to make your own docker image"! Next, please follow the editor to study!

Make modifications to the container

We run a container and enter it, and customize it (install and modify)

[root@srv00 ~] # docker run-it centos [root@8a15586148ee /] # cat / etc/yum.repos.d/nginx.repo > [nginx] > name=nginx repo > baseurl= http://nginx.org/packages/centos/7/\$basearch/ > gpgcheck=0 > enabled=1 > EOF [root@8a15586148ee /] # yum install-y nginx [root@8a15586148ee /] # exit

Save the changes to the container. Kind of like git commit.

[root@srv00 ~] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES8a15586148ee centos "/ bin/bash" 21 minutes ago Exited (0) About a minute ago naughty_ dubinsky [root @ srv00 ~] # Docker commit-m "install nginx"-a "hippo" 8a15586148ee hippo/nginx:v1.10sha256:1e20546f8434d72cb350ae2081fc77690bdc599dbd984b5cdec09a7868013042

View the image created under

[root@srv00 ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEhippo/nginx v1.10 1e20546f8434 About a minute ago 281.1 MBcentos latest 8596123a638e 2 days ago 196.7 MB

Give it a try.

[root@srv00] # docker run-d-p 80 hippo/nginx:v1.10 nginx-g "daemon off "616d942216ee7050ecff07ca66d2d7583d4093820e9d1448f96b417d7d779408 [root@srv00 ~] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES616d942216ee hippo/nginx:v1.10" nginx-g'daemon off "4 seconds ago Up 2 seconds 0.0.0.0 docker ps 32770-> 80/tcp high _ shockley [root@srv00 ~] # curl-L localhost:32770Welcome to nginxcake.

-d runs in the background, and-p maps the container port to the host. You can see through docker ps that it is mapped to 32770. Commands running in the nginx-g daemon off; container need to be run in the foreground. Otherwise, after starting the container, it will exit immediately.

At this point, the study on "how to make your own docker image" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report