Docker
This page contains technical information and links about the Docker. If you are new to Docker, you might want to checkout out the Container page to get some information about the concept of a container and then come back here later.
This page is work in progress. At the bottom of the page you can find a list of topics that still should be documented here. If you land here and have some spare time, why not help out?
Docker is an established technology and you can find plenty of information about it online. On this page we collect links to resources that we have found useful for learning and as a reference, as well as best-practices and conventions that are specific to how VSETH uses Docker. Please note that this page should not become another docker documentation.
VSETH Specific
Best Practices for Writing Docker Files
General
This is a list of general best practices when writing docker files and are not SIP specific:
- You can use a tool such as: https://www.fromlatest.io/#/ to improve your docker files
- A few tipps for reducing docker file size: https://hackernoon.com/tips-to-reduce-docker-image-sizes-876095da3b34 (but keep in mind: size is not everything, an understandable Dockerfile is much better than one that is a few Bytes smaller but nobody can understand ...)
- Prefer COPY --chown=app-user:app-user over dedicated RUN chown
- Only copy what is really needed (the image doesn't need sip.yml, go/java/.. source files, .git directory, etc)
- verify hashes of binaries you integrate during build, see example
SIP specific
- Do not use `apt-get update` in your docker files
- Prefer curl over wget as the base image already contains it
- Do not specify CMD or ENTRYPOINT
- use USER instead of installing sudo. Remember to have USER root as last USER instruction, otherwise the container won't start
To Document
This page should be extend to contain more information about:
- How to write Dockerfile
- Base Image, inherit from other images
- Basic steps: ADD, COPY, RUN, WORKDIR, USER
- Testing and Developing with docker-compose
- Start infrastructure components like databases and "fake-mailserver" (Mailhog): https://github.com/mailhog/MailHog
- Configuration of running containers:
- How can running containers access information from the outside infrastructure, such as database credentials?
- VSETH: uses Environment variables for this
- What executable is executed?
- ENTRYPOINT: https://docs.docker.com/engine/reference/builder/#entrypoint
- Init Process: many people use: https://github.com/krallin/tini
- VSETH: uses cinit
- Docker CLI
- docker ps
- docker exec -it (execute a command inside a running container)
- docker logs
- docker-compose up --build