Home >Operation and Maintenance >Docker >Introduction to the usage of build command

Introduction to the usage of build command

王林
王林forward
2020-11-04 15:38:4610402browse

Introduction to the usage of build command

After the Dockerfile is created, you can use the docker build command to build an image based on the Dockerfile.

(Programming video recommendation: java video tutorial)

1. First prepare the Dockerfile:

Introduction to the usage of build command

2 . Execute the build command:

docker build -t second:v1.0 .

Note that there is a point at the end. By default, "the file named Dockerfile under the context directory (Context) is used as the Dockerfile". Here, the Dockerfile in the current path is used to build.

-t second : v1.0 Name the newly built image second and set the version to v1.0.

Introduction to the usage of build command

#docker build: Command keyword to build the image using Dockerfile.

[OPTIONS]: Command options, commonly used instructions include

-t specifies the name of the image,

-f displays the Dockerfile file that specifies the built image (Dockerfile may not be the current one) path)

If -f is not used, the file named Dockerfile under the context path is considered to be the "Dockerfile" for building the image by default.

Context path|URL: Specify the path of the context for building the image. During the process of building the image, any file in the context can and can only be referenced.

3. You can use docker images to check whether the build is successful.

Related recommendations: docker tutorial

The above is the detailed content of Introduction to the usage of build command. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete