| 1. |
You Say That Ansible Can Take Up To 20x Longer To Provision, But Why? |
|
Answer» Docker uses cache to speed up builds SIGNIFICANTLY. Every command in DOCKERFILE is BUILD in another docker container and it’s results are stored in separate layer. Layers are built on top of each other. Docker scans Dockerfile and try to execute each steps one after another, before executing it probes if this layer is already in cache. When cache is hit, building step is skipped and from user perspective is almost instant. When you build your Dockerfile in a way that the most changing things such as application source code are on the bottom, you would experience instant builds. You can learn more about caching in docker in this article. Another way of amazingly fast building docker images is using good base image – which you specify inFROM command, you can then only make NECESSARY changes, not rebuild everything from scratch. This way, build will be quicker. It’s especially beneficial if you have a HOST without the cache like Continuous Integration server. Summing up, building docker images with Dockerfile is faster than provisioning with ansible, because of using docker cache and good base images. Moreover you can completely eliminate provisioning, by using ready to use configured images such stgresus. $ docker run --name some-postgres -d postgres No installing postgres at all - it's ready to run. Docker uses cache to speed up builds significantly. Every command in Dockerfile is build in another docker container and it’s results are stored in separate layer. Layers are built on top of each other. Docker scans Dockerfile and try to execute each steps one after another, before executing it probes if this layer is already in cache. When cache is hit, building step is skipped and from user perspective is almost instant. When you build your Dockerfile in a way that the most changing things such as application source code are on the bottom, you would experience instant builds. You can learn more about caching in docker in this article. Another way of amazingly fast building docker images is using good base image – which you specify inFROM command, you can then only make necessary changes, not rebuild everything from scratch. This way, build will be quicker. It’s especially beneficial if you have a host without the cache like Continuous Integration server. Summing up, building docker images with Dockerfile is faster than provisioning with ansible, because of using docker cache and good base images. Moreover you can completely eliminate provisioning, by using ready to use configured images such stgresus. $ docker run --name some-postgres -d postgres No installing postgres at all - it's ready to run. |
|