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

The method of customizing Container Image in docker

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

Share

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

How to customize the container image in docker? There are many images in docker that can be used directly, but when these images do not meet the requirements, or when a new project wants to use docker, you need a custom container image. Taking the custom Nginx image as an example, we use Dockerfile to customize it.

In a blank directory, create a text file and name it Dockerfile:

$mkdir mynginx$ cd mynginx$ touch Dockerfile

The content is:

FROM nginxRUN echo 'Hello, Docker' > / usr/share/nginx/html/index.html

This Dockerfile is very simple, a total of two lines. Two instructions are involved, FROM and RUN.

Execute in the same directory as the Dockerfile file:

$docker build-t nginx:v3 .Sending build context to Docker daemon 2.048 kBStep 1: FROM nginx--- > e43d811ce2f4Step 2: RUN echo 'Hello, Docker' > / usr/share/nginx/html/index.html--- > Running in 9cdc27646c7bMurray-> 44aa4490ce2cRemoving intermediate container 9cdc27646c7bSuccessfully built 44aa4490ce2c

Here we use the docker build command to build the image. Its format is:

Docker build [options]

The container cloud is realized by deploying container services on cluster servers through docker technology, with tens of thousands of Linux images, powerful, easy to use, easy to serve as cluster services, free networking, lightweight and flexible.

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