f3916da35b6b redis 0.15% 3.043MiB / 15.55GiB 0.02% 13.2kB / 0B 2.97MB / 0B 4
f97e0697db61 node_api 0.00% 65.52MiB / 15.55GiB 0.41% 862kB / 8.23kB 137MB / 24.6kB 20
8c0d1adc9b9c portainer 0.00% 8.859MiB / 15.55GiB 0.06% 102kB / 3.87MB 57.8MB / 122MB 20
6018b7e3d9cd node_payin 0.00% 9.297MiB / 15.55GiB 0.06% 222kB / 3.04kB 82.4MB / 24.6kB 11
^ C
When creating images, you need to consider:
** changing a large layer, it will be recreated, so it is often better to split it, for example, create one layer with 'NPM i' and copy the code on the second;
* if the file in the image is large and the container is changed, then from the read-only image layer the file will be completely copied to the editing layer, therefore, the containers are supposed to be lightweight, and the content is usually placed in a special storage. code-as-a-service: 12 factors (12factor.net)
* Codebase – one service – they are a repository;
* Dependeces – all dependent services in the config;
* Config – configs are available through the environment;
* BackEnd – exchange data with other services via an API-based network;
* Processes – one service – one process, which allows in the event of a fall to unambiguously track (the container itself ends) and restart it;
* Independence of the environment and no influence on it.
* СI / CD – code control (git) – build (jenkins, GitLab) – relies (Docker, jenkins) – deploy (helm, Kubernetes). Keeping the service lightweight is important, but there are programs not designed to run in containers like databases. Due to their peculiarity, certain requirements are imposed on their launch, and the profit is limited. So, because of big data, they are not only slow to scale, and rolling-abdate is unlikely, and the restart must be performed on the same nodes as their data for reasons of performance of access to them.
* Config – service relationships are defined in the configuration, for example, docker-compose.yml;
* Port bindign – services communicate through ports, while the port can be selected automatically, for example, if EXPOSE PORT is specified in the Dockerfile, then when a container is called with the -P flag, it will be terminated to the free one automatically.
* Env – environment settings are passed through environment variables, not through configs, which allows them to be added to the service config configuration, for example, docker-compose.yml
* Logs – logs are streamed over the network, for example, ELK, or printed to the output, which is already streamed by Docker.
Dockerd internals:
essh @ kubernetes-master: ~ / mongo-rs $ ps aux | grep dockerd
root 6345 1.1 0.7 3257968 123640? Ssl Jul05 76:11 / usr / bin / dockerd -H fd: // –containerd = / run / containerd / containerd.sock
essh 16650 0.0 0.0 21536 1036 pts / 6 S + 23:37 0:00 grep –color = auto dockerd
essh @ kubernetes-master: ~ / mongo-rs $ pgrep dockerd
6345
essh @ kubernetes-master: ~ / mongo-rs $ pstree -c -p -A $ (pgrep dockerd)
dockerd (6345) – + – docker-proxy (720) – + – {docker-proxy} (721)
| | – {docker-proxy} (722)
| | – {docker-proxy} (723)
| | – {docker-proxy} (724)
| | – {docker-proxy} (725)
| | – {docker-proxy} (726)
| | – {docker-proxy} (727)
| `– {docker-proxy} (728)
| -docker-proxy (7794) – + – {docker-proxy} (7808)
Docker-File:
* cleaning caches from package managers: apt-get, pip and others, this cache is not needed in production, only
takes up space and loads the network, but nowadays it is not often not relevant, since there are multi-stage
assembly, but more on that below.
* group commands of the same entities, for example, get APT cache, install programs and uninstall