1
+ <!DOCTYPE html>
2
+ < html >
3
+ < title > Akash Singh</ title >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
6
+ < link rel ="stylesheet " href ="https://www.w3schools.com/w3css/4/w3.css ">
7
+ < link rel ="stylesheet " href ="https://fonts.googleapis.com/css?family=Inconsolata ">
8
+ < style >
9
+ body , html {
10
+ height : 100% ;
11
+ font-family : "Inconsolata" , sans-serif;
12
+ }
13
+ .bgimg {
14
+ background-position : center;
15
+ background-size : cover;
16
+ background-image : url ("./img/ml.jpg" );
17
+ min-height : 75% ;
18
+ }
19
+ .menu {
20
+ display : none;
21
+ }
22
+ .container {
23
+ width : 80% ;
24
+ margin : auto;
25
+ }
26
+ .code {
27
+ background-color : # eee ;
28
+ border-radius : 3px ;
29
+ font-family : courier, monospace;
30
+ padding : 0 3px ;
31
+ }
32
+ .boxed {
33
+ border : 1px solid green ;
34
+ }
35
+ </ style >
36
+ < body >
37
+ <!-- Links (sit on top) -->
38
+ < div class ="w3-top ">
39
+ < div class ="w3-row w3-padding w3-black ">
40
+ < div class ="w3-col s3 ">
41
+ < a href ="https://akashzcoder.github.io " class ="w3-button w3-block w3-black "> HOME</ a >
42
+ </ div >
43
+ < div class ="w3-col s3 ">
44
+ < a href ="https://akashzcoder.github.io/#about " class ="w3-button w3-block w3-black "> ABOUT</ a >
45
+ </ div >
46
+ < div class ="w3-col s3 ">
47
+ < a href ="https://akashzcoder.github.io/#resume " class ="w3-button w3-block w3-black "> RESUME</ a >
48
+ </ div >
49
+ < div class ="w3-col s3 ">
50
+ < a href ="https://akashzcoder.github.io/#academicWriting " class ="w3-button w3-block w3-black "> BLOGS</ a >
51
+ </ div >
52
+ </ div >
53
+ </ div >
54
+ < div class ="w3-grayscale w3-large ">
55
+ <!-- About Container -->
56
+ < p class ="w3-container container " id ="about ">
57
+ < p class ="w3-content " style ="max-width:700px ">
58
+ < h5 class ="w3-center w3-padding-64 "> < span class ="w3-tag w3-wide "> Docker Volumes</ span > </ h5 >
59
+ </ p >
60
+ < p class ="w3-content " style ="max-width:900px ">
61
+ When a container writes files, it writes them inside of the container.
62
+ Which means that when the container dies (the host machine restarts or the container is moved from one node
63
+ to another in a cluster, it simply fails, etc.) all of that data is lost. It also means that if you run the
64
+ same container several times in a load-balancing scenario, each container will have its own data, which may
65
+ result in inconsistent user experience.< br > < br >
66
+ A rule of thumb for the sake of simplicity is to ensure that containers are stateless, for instance, storing
67
+ their data in an external database (relational like an SQL Server or document-based like MongoDB) or
68
+ distributed cache (like Redis). However, sometimes you want to store files in a place where they are
69
+ persisted; this is done using volumes.
70
+ < br > < br >
71
+ Using a volume, you map a directory inside the container to a persistent storage. Persistent storages are
72
+ managed through drivers, and they depend on the actual Docker host. They may be an Azure File Storage on
73
+ Azure or Amazon S3 on AWS. With Docker Desktop, you can map volumes to actual directories on the host system;
74
+ this is done using the -v switch on the docker run command or if you are using Docker-compose you can simply
75
+ set the volume there.
76
+ < br > < br >
77
+ Suppose you run a Oracle database with no volume:< br >
78
+ < code > docker run -d oraclelinux:7-slim</ code >
79
+ < br >
80
+ Any data stored in that database will be lost when the container is stopped or restarted.
81
+ In order to avoid data loss, you can use a volume mount:< br >
82
+ < code >
83
+ docker run -v /your/dir:/var/lib/oraclelinux -d oraclelinux:7-slim
84
+ </ code > < br >
85
+ < br >
86
+ It will ensure that any data written to the < i > /var/lib/oraclelinux</ i > directory inside the container is actually
87
+ written to the < i > /your/dir</ i > directory on the host system.
88
+ This ensures that the data is not lost when the container is restarted.
89
+ Another very big advantage is that it allows to edit the code inside your volume which takes effect upon
90
+ restarting the container. This means that we can actually make code changes persistent.
91
+
92
+ </ p >
93
+ </ div >
94
+ </ div >
95
+ </ div >
96
+ <!-- Footer -->
97
+ < footer class ="w3-center w3-light-grey w3-padding-48 w3-large ">
98
+ < blockquote >
99
+ < cite > References:< br > [1] < a href ="https://docs.docker.com/develop/develop-images/multistage-build/ "> https://docs.docker.com/develop/develop-images/multistage-build/</ a > </ cite >
100
+ </ blockquote >
101
+ < p >
102
+ Copyright © 2020 · Akash Singh
103
+ </ p >
104
+ </ footer >
105
+ < script >
106
+ // Tabbed Menu
107
+ function openMenu ( evt , menuName ) {
108
+ var i , x , tablinks ;
109
+ x = document . getElementsByClassName ( "menu" ) ;
110
+ for ( i = 0 ; i < x . length ; i ++ ) {
111
+ x [ i ] . style . display = "none" ;
112
+ }
113
+ tablinks = document . getElementsByClassName ( "tablink" ) ;
114
+ for ( i = 0 ; i < x . length ; i ++ ) {
115
+ tablinks [ i ] . className = tablinks [ i ] . className . replace ( " w3-dark-grey" , "" ) ;
116
+ }
117
+ document . getElementById ( menuName ) . style . display = "block" ;
118
+ evt . currentTarget . firstElementChild . className += " w3-dark-grey" ;
119
+ }
120
+ document . getElementById ( "myLink" ) . click ( ) ;
121
+ </ script >
122
+
123
+ </ body >
124
+ </ html >
0 commit comments