This document covers recommended best practices & methods for buildingefficient images.
Bạn đang xem: Stored procedure là gì
vuialo.net builds images automatically by reading the instructions from avuialo.netfile -- a text file that contains all commands, in order, needed tobuild a given image. A vuialo.nettệp tin adheres to lớn a specific format và set ofinstructions which you can find at vuialo.netfile reference.
A vuialo.net image consists of read-only layers each of which represents avuialo.netfile instruction. The layers are stacked và each one is a delta of thechanges from the previous layer. Consider this vuialo.netfile:
# syntax=vuialo.net/vuialo.netfile:1FROM ubuntu:18.04COPY . /appRUN make /appCMD pybé /app/ứng dụng.py
Each instruction creates one layer:
When you run an image & generate a container, you add a new writable layer(the “container layer”) on top of the underlying layers. All changes made tothe running container, such as writing new files, modifying existing files, anddeleting files, are written khổng lồ this writable container layer.
For more on image layers (và how vuialo.net builds và stores images), seeAbout storage drivers.
General guidelines và recommendations
Create ephemeral containers
The image defined by your vuialo.netfile should generate containers that are asephemeral as possible. By “ephemeral”, we mean that the container can be stoppedvà destroyed, then rebuilt & replaced with an absolute minimum mix up andconfiguration.
Xem thêm: Hướng Dẫn Cài Đặt Teamviewer 9 Trên Môi Trường Linux, Hướng Dẫn Cài Đặt Teamviewer 9 Trên Linux
Refer to lớn Processes under The Twelve-factor Appmethodology khổng lồ get a feel for the motivations of running containers in such astateless fashion.
Underst& build context
When you issue a vuialo.net build commvà, the current working directory is calledthe build context. By mặc định, the vuialo.nettệp tin is assumed lớn be located here,but you can specify a different location with the file flag (-f). Regardlessof where the vuialo.nettệp tin actually lives, all recursive contents of files anddirectories in the current directory are sent lớn the vuialo.net daetháng as the buildcontext.
Build context example
Create a directory for the build context & cd into lớn it. Write “hello” intoa text file named hello và create a vuialo.nettệp tin that runs cát on it. Buildthe image from within the build context (.):
$ mkdir myproject &và cd myproject$ echo "hello" > hello$ eđến -e "FROM busybox
COPY /hello /
RUN cat /hello" > vuialo.netfile$ vuialo.net build -t helloapp:v1 .
Move vuialo.nettệp tin và hello inkhổng lồ separate directories và build a secondversion of the image (without relying on cache from the last build). Use -fkhổng lồ point to the vuialo.netfile and specify the directory of the build context:
$ mkdir -p vuialo.netfiles context$ mv vuialo.nettệp tin vuialo.netfiles && mv hello context$ vuialo.net build --no-cabịt -t helloapp:v2 -f vuialo.netfiles/vuialo.nettệp tin context
Inadvertently including files that are not necessary for building an imageresults in a larger build context và larger image form size. This can increase thetime lớn build the image, time lớn pull & push it, and the container runtimekích cỡ. To see how big your build context is, look for a message lượt thích this whenbuilding your vuialo.netfile:
Sending build context to vuialo.net daemon 187.8MB
Pipe vuialo.netfile through stdin
vuialo.net has the ability lớn build images by piping vuialo.netfile through stdinwith a local or remote build context. Piping a vuialo.nettệp tin through stdincan be useful to persize one-off builds without writing a vuialo.netfile khổng lồ disk,or in situations where the vuialo.nettệp tin is generated, and should not persistafterwards.The examples in this section use here documentsfor convenience, but any method khổng lồ provide the vuialo.nettệp tin on stdin can beused.