Monday, May 30, 2016

Deal with Docker

http://www.markbetz.net/2014/03/17/docker-run-startup-scripts-then-exit-to-a-shell/



LOADBALANCING CONTAINERS WITH DOCKER-COMPOSE
https://eyenx.ch/2015/04/18/loadbalancing-containers-with-docker-compose

https://blog.giantswarm.io/moving-docker-container-images-around/


https://github.com/wsargent/docker-cheat-sheet

Dockers containers built with a Dockerfile can get quite large. We slim down our containers by these simple tricks before publishing.

Cleaning APT

The obvious apt-clean for cleaning out the apt-cache and cleaning out tmp.
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Flatten an image

A Dockerfile builds your container in many individual steps. Resulting in a container with some overhead. Whenever you want to remove the excess overhead you can flatten your image by exporting and importing and creating an new image. This is a handy trick for creating base images.
ID=$(docker run -d image-name /bin/bash)
docker export $ID | docker import – flat-image-name
Thanks for the tip Kryztoval!
If you want to save it for backup you can use gzip to compress the image.
ID=$(docker run -d image-name /bin/bash)
(docker export $ID | gzip -c > image.tgz)
gzip -dc image.tgz | docker import - flat-image-name
Got any better ways to slim down your containers? Please post in the comments!

No comments:

Post a Comment