Detailed explanation of the use of Docker commit

Detailed explanation of the use of Docker commit

Sometimes you need to install certain dependencies in the base image. If you write the commands in the Dockerfile, some dependent software will download very slowly, and it will take a long time to build the image. So it is best to install a new image that contains the dependent libraries.

Docker provides commit to achieve

For example, I have a python image, which is relatively streamlined. The two dependencies freetds-dev and unixodbc-dev are missing.

1. Run the image first

docker run -it --name python docker.io/python:3.6.4 /bin/bash

/bin/bash enters the container to interact

2. Execute the installation command

root@39eaa5aa7332:/code# apt-get install freetds-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
root@39eaa5aa7332:/code# apt-get install unixodbc-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done

After the installation is complete, press ctrl+p+q to exit the container.

3. Package the container into an image and execute docker commit

[root@CentOS ~]# docker commit 39eaa5aa7332 python3.6.4-dev
sha256:ca46b1ed99abc1338881a55a043ee9670a66601530b3f2e63f41eb949b91e84d

Then execute docker images to see this image

The above is a detailed explanation of the use of Docker commit. For more information about the use of Docker commit, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Detailed explanation of the working principle and usage of the Docker image submission command commit
  • Docker learning notes: How to commit a container to an image
  • Detailed explanation of Docker modifying existing images (commit)
  • Detailed explanation of Docker learning to create an image using the commit command

<<:  Detailed explanation of the idea of ​​using mysqldump+expect+crontab to implement mysql periodic cold backup in linux

>>:  Let's talk about the Vue life cycle in detail

Recommend

Detailed explanation of identifying files with the same content on Linux

Preface Sometimes file copies amount to a huge wa...

Some conclusions on the design of portal website focus pictures

Focus images are a way of presenting content that ...

Thoughts on truncation of multi-line text with a "show more" button

I just happened to encounter this small requireme...

How to implement scheduled backup of MySQL database

1. Create a shell script vim backupdb.sh Create t...

How to implement online hot migration of KVM virtual machines (picture and text)

1. KVM virtual machine migration method and issue...

A complete list of commonly used MySQL functions (classified and summarized)

1. Mathematical Functions ABS(x) returns the abso...

Why MySQL does not recommend using subqueries and joins

To do a paginated query: 1. For MySQL, it is not ...

Linux remote login implementation tutorial analysis

Linux is generally used as a server, and the serv...

Vue3.0 handwritten carousel effect

This article shares the specific code of Vue3.0 h...

How to add shortcut commands in Xshell

As a useful terminal emulator, Xshell is often us...

JQuery implements hiding and displaying animation effects

This article shares the specific code of JQuery t...

Detailed explanation of the code for implementing linear gradients with CSS3

Preface The gradient of the old version of the br...

Solve the matching problem in CSS

Problem Description As we all know, when writing ...