Image¶
Every statement like RUN, COPY or ADD in the dockerfile will add a layer into docker image.
run image¶
docker run -it <image-id> #from default entrypoint
docker run -it --entrypoint /bin/bash <image-id> #from another entrypoint
list images with sort¶
remove image with multiple repos/tags¶
check docker image layer sizes¶
Usedive to check layer content: https://github.com/wagoodman/dive reduce docker image size¶
https://jcristharif.com/conda-docker-tips.html
https://uwekorn.com/2021/03/01/deploying-conda-environments-in-docker-how-to-do-it-right.html
Use an official base image whenever possible
Use variations of Alpine images when possible
Every
RUNinstruction in theDockerfilewrites a new layer in the imageEvery layer requires extra space on disk
To keep the number layers to a minimum, commands should be combined into a single RUN instruction
Free spaces after
updateusingapt clean allUse multistage builds
Use .dockerignore to exclude files not needed
Squash layers: https://github.com/goldmann/docker-squash
Conda docker image size¶
https://pythonspeed.com/articles/conda-docker-image-size/
Use conda-pack to remove conda and use multistage build together to reduce image size.
The base Conda environment is necessary for installation of packages, but once we’re running the code it really doesn’t add much.