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

What is the use of ADD and COPY instructions in Dockerfile

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

Share

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

This article mainly introduces what is the use of ADD and COPY instructions in Dockerfile. It is very detailed and has a certain reference value. Interested friends must read it!

When build Docker an image from Dockerfile, you can choose two commands to add local directories or files to your image: ADD and COPY. The two instructions are basically the same format and basically the same thing.

ADD...

COPY...

In both cases, the directory or file () is copied and added to the specified path in the container's file system ()

The ADD instruction allows you to use URL as an argument. When you encounter URL, you can download the file through URL and copy it to.

Another feature of ADD is the ability to extract files automatically. If the parameter is a local file in a recognized compressed format (tar, gzip, bzip2, etc) (so it cannot be downloaded and unzipped at the same time), it will be extracted to the path of the specified container file system.

Interestingly, the URL download and decompression features cannot be used together. Any compressed file copied via URL will not be decompressed automatically.

Currently the ADD command is IMO far too magical. It can add local and remote files. It will sometimes untar a file and it will sometimes not untar a file. If a file is a tarball that you want to copy, you accidentally untar it. If the file is a tarball in some unrecognized compressed format that you want to untar, you accidentally copy it.

COPY does not support URL and does not give special treatment to compressed files. If the decompression is not specified in the upper and lower files of the build, it will not be decompressed automatically, only the compressed files will be copied to the container.

These are all the contents of the article "what are the ADD and COPY instructions in Dockerfile?" Thank you for reading! Hope to share the content to help you, more related knowledge, 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

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report