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 use docker commit to extend an image

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use docker commit to expand an image, I hope you will learn something after reading this article, let's discuss it together!

Start the container with image, update it, and then submit the results to the new image.

$sudo docker run-t-I training/sinatra / bin/bash

Root@0b2616b0e5a8:/#

Note: remember the ID of the container, which we will use later

Here we add json gem to the container

Root@0b2616b0e5a8:/# gem install json

When it's over, we use exit to exit, and now our container has been changed by us, using the docker commint command

To submit the corresponding copy.

$sudo docker commit-m = "Added json gem"-a = "Kate Smith" 0b2616b0e5a8 ouruser/sinatra:v2

4f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7fc3231110e7f71b1c

-m to specify the submitted information, just like the version control tool we use.

-a can specify the user information we updated, specify the container ID from which we want to create our copy, and finally specify the target image

Donovan's name.

In this example, we specify a new user, ouruser, using sinatra's image, and finally specify image's

Mark v2.

Use docker images to view the new image we created.

$sudo docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

Training/sinatra latest 5bc342fa0b91 10 hours ago 446.7 MB

Ouruser/sinatra v2 3c59e02ddd1a 10 hours ago 446.7 MB

Ouruser/sinatra latest 5db5f8471261 10 hours ago 446.7 MB

Use the new image to start the container

$sudo docker run-t-I ouruser/sinatra:v2 / bin/bash

Root@78e82f680994:/#

After reading this article, I believe you have a certain understanding of "how to use docker commit to expand an image". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

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