First Commit

This commit is contained in:
2024-12-02 15:11:30 +01:00
commit 031f6004de
4688 changed files with 441558 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
- Use layers wisely: they will make things a lot faster when rebuilding dockerfiles
- Use multi-stage builds: like that only what is needed to execute the final project is actually included in the image. The first layer, where the image gets compiled contains all resources needed for compilation. Those are not shared with the final image --> footprint is drastically reduced
- multi-stage builds also make compilation a lot faster, since multiple commands that depend on the first initial stage can be built simultaneously
- Use multiple targets to build multiple images from one docker build
## Images
- `scratch`: is a empty docker image: it is the smallest docker image there is and should be used to build shippable images
# Networks
# Conflict with [[UFW]]
# Space Problem
Dockers default root directory is `/var/lib/docker` which is part of the the root partition (if your machine is set up with a separate root and home partition). Often the root partition does contain a lot less available space than the home partition. However, docker can use a lot of space, since it needs to pull entire images from the web and store intermediate builds as well. By default it does not delete old files. One option would be to resize the root partition, but it is cumbersome, especially in a live system.
What have I done to overcome this problem?
I have deleted all docker files and then redefined where docker stores its files ([this website](https://www.baeldung.com/linux/docker-fix-no-space-error#changing-the-default-storage-location) helped a lot).
1. Check the current docker root directory: `docker info -f '{{.DockerRootDir }}'` --> this points to `/var/lib/docker` by default.
2. Prune all docker files. Attention, this deletes all docker related files, make sure that your data is save (if its only stored within a docker container, it will be lost):
1. `docker container prune; docker image prune; docker volume prune`
2. `docker system prune -a --volumes`
3. Redefine where the docker root folder is by creating or modifying the file `/etc/docker/daemon.json`:
1. `sudo vim /etc/docker/daemon.json`
```json
{
"data-root": "/path/to/new/root/folder"
}
```
4. Restart the docker daemon: `sudo systemctl restart docker`
5. Verify the new docker root dir by rerunning the command of step 1.
Now you should be able to rebuild the docker containers that caused the problems with success.