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 many methods are there to create docker images

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

Share

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

How many methods are there to create docker images? To solve this problem, today the editor summarizes this article on the creation of docker images, hoping to help more friends who want to solve this problem to find a more simple and easy way.

There are three ways to create an image: based on an existing image, based on a local template, and based on docker.

Create based on an existing image

Creating based on an existing image mainly uses the docker commit command

Common options:

-m: description information

-a: author information

-p: stop the container during the build process

Command format

Docker commit [options] Container id/ name Warehouse name: [label]

Created based on a local template

An image can be generated by importing the operating system template file. The template can be downloaded from the OPENVZ open source project at http://openvz.org/Download/template/precreated

Download the ubuntu template package and import it as a local image using the docker import command

Create based on dockerfile

The dockerfile structure is roughly divided into four parts: basic image information, maintainer information, mirror operation instructions and instructions executed when the container starts.

# Import a centos container in advance

1. Create a working directory

two。 Create and write dockerfile files

3. Write and execute script content

4. Create a test web page

5. Use dockerfile to generate an image

After writing dockerfile and related content, you can use the docker build command to create a mirror

Command format

Docker build [option] path

Common option

-t specifies the label information of the image

# Last point. Represents the current path.

6. Run the container with a new image

-p 12345 80 means to map port 80 to local port 12345

Finally, you can use web access to test it.

If you can read this, congratulations, you already have the most practical experience of how to create docker images. If you want to read more related articles, you are welcome to follow the industry information channel!

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