• Martin Thoma
  • Home
  • Categories
  • Tags
  • Archives
  • Support me

How to Speed up Docker

Contents

  • Install Early, Copy Late
  • .dockerignore
  • See also

Building a Docker container can take quite a while. However, there are some easy parts to speed them up.

This is an article I had for quite a while as a draft. As part of my yearly cleanup, I've published it without finishing it. It might not be finished or have other problems.

Install Early, Copy Late

Make sure you install dependencies early and copy code late during building the container. This helps to cache the dependencies.

You might also want to look at dependency pinning.

.dockerignore

Make sure you don't re-build the container with stuff you don't need.

You can check the included files via

sudo docker build -t test .
sudo docker run --entrypoint /usr/bin/find -it test
sudo docker images | grep ^test

When I started looking at the size of my Flask image, it was 357MB. Without copying any of the code, it was 349MB.

See also

  • Do not ignore .dockerignore
  • Differences of Rules Between .gitignore and .dockerignore

Published

Dez 31, 2019
by Martin Thoma

Category

Code

Tags

  • Docker 3

Contact

  • Martin Thoma - A blog about Code, the Web and Cyberculture
  • E-mail subscription
  • RSS-Feed
  • Privacy/Datenschutzerklärung
  • Impressum
  • Powered by Pelican. Theme: Elegant by Talha Mansoor