Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of customizing Container Image in docker

Shulou Source: shulou.com Published: 2022-06-03 05:50:17 09月21日 Update

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.

Tags: Image container service file directory cluster method powerful free content function powerful command location technology instruction text server format blank Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB MySQL Shulou Technology NVidia