The best way to create docker image "offline installer"

Viewed 2773

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?

2 Answers

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.

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.

Related