-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathsession-54.txt
More file actions
72 lines (59 loc) · 2.46 KB
/
Copy pathsession-54.txt
File metadata and controls
72 lines (59 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
1. Build image
best practices implement
2. Run image
best practices implement
Docker architecture
===================
1. docker checks image is available in local or not
2. if available it will run
3. if not available, it will pull from the hub
4. creates container out of it
5. send the output to user
Docker client == Docker CLI
Docker deamon == docker software running
docker run nginx -> checks whether nginx is available in local
if available creates container out of it and show to client
if not available pull from hub, store it in local, create container and show to client
volumes
========
1. un-named volumes -> managed by us
2. named volumes -> use docker commands to create and manage the container volumes
Docker best practices
======================
1. Use Minimal Base Images. alpine images are minimal, but use official
node:20 built on ubuntu/debian
2. Use Multi-Stage Builds
multi stage builds have multiple FROM instructions, basically looks multiple Dockerfiles. One Dockerfile is used to provide the artifact. we can copy the artifact into run time image... when you are installing dependencies there might be cache, dev related tools, etc are installed. those are not required for running into production..
node artifact = code + node_modules
java = .jar file
3. use dockerignore -> don't un necessary files/folders
4. Don’t Run as Root
5. Avoid using latest -> we will not be sure which version actually running
6. Use volumes if containers are stateful, prefer stateless apps inside containers not stateful
7. Use ENV variables at runtime instead of build time.. no need to rebuild the image
8. Health Checks
9. Scan Images for Vulnerabilities
10. Use Proper Logging
11. Limit Container Resources
12. Use ENTRYPOINT + CMD Correctly
13. Version and Tag Images Properly prefer semantic version
14. Optimise layers
15. Use secrets, dont hardcodes creds
1.0.0 -> major-version.minor-version.patch-version
20
20.1
20.2
20.3 -> released public
20.3.1 -> 20 major-version 3 minor 1 patch-version
Docker disadvantages to run images
==================================
1. you can't rely on single docker host
2. if run multiple hosts, there needs to be some orchestrator
3. container to container communication is difficult if we run in docker
4. if there is load on application, there should be load balancing
5. autoscaling is not there
6. networking...
7. where to store secrets?
8. volumes implementation is not good
Docker swarm, kubernetes, mesos, etc..
EKS, AKS, GKE, Openshift