The best way to create docker image “offline installer”

会有一股神秘感。 提交于 2020-01-06 04:42:07

问题


I use docker-compose file to get Elasticsearch Logstash Kibana stack. Everything works fine,

docker-compose build

command creates three images, about 600 MB each, downloads from docker repository needed layers.

Now, I need to do the same, but at the machine with no Internet access. Downloading from respositories there is impossible. I need to create "offline installer". The best way I found is

docker save image1 image2 image3 -o archivebackup.tar

but created file is almost 2GB. During

docker-compose build

command some data are downloaded from the Internet but it is definitely less than 2GB.

What is a better way to create my "offline installer", to avoid making it so big?


回答1:


The save command is the way to go for running docker images online.

The size difference that you are noticing is because when you are pulling images from a registry, some layers might exist locally and are thus not pulled. So you are not pulling all the image layers, only the ones that you don't have locally.

On the other hand, when you are saving the image to a tar, all the layers need to be stored.




回答2:


The best way to create the Docker offline Installer is to

  • List item
  • Get the CI/CD pipeline to generate the TAR file as build process.
  • Later create a local folder with the required TAR files
  • Write a script to load these TAR files on the machine
  • The same script can fire the docker-compose up -d command to bring up the whole service ecosystem

Note : It is important to load the images before bringing up the services

Regarding the size issue the answer by Yamenk specifically points to the reason why the size increases. The reason is docker does not pull the shared layers.



来源:https://stackoverflow.com/questions/46560026/the-best-way-to-create-docker-image-offline-installer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!