You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DOCKERFILE.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ In the example above, each instruction creates one layer:
65
65
-`RUN` builds your application with `make`.
66
66
-`CMD` specifies what command to run within the container.
67
67
68
-
**Note** : When you run an image and generate a container, you add a new _writable layer_, also called the container layer, on top of the underlying layers. All changes made to the running container, such as writing new files, modifying existing files, and deleting files, are written to this writable container layer (writable layer is not persistent, [read about that here](README.md#volumes-card_file_box) ).
68
+
**Note** : When you run an image and generate a container, you add a new _writable layer_, also called the container layer, on top of the underlying layers. All changes made to the running container, such as writing new files, modifying existing files, and deleting files, are written to this writable container layer (writable layer is not persistent, [read about that here](docker/Notes/README.md#volumes-card_file_box) ).
69
69
70
70
71
71
## Dockerfile Instructions Reference
@@ -266,7 +266,7 @@ _Multi-stage builds_ allow us to create a Dockerfile that defines multiple stag
266
266
267
267
The key advantage of using multi-stage builds is that it allows developers to reduce the size of the final image. By breaking down the build process into smaller stages, it becomes easier to remove unnecessary files and dependencies that are not needed in the final image. This can significantly reduce the size of the image, which can lead to faster deployment times and lower storage costs.
268
268
269
-
In addition to reducing image size, multi-stage builds can also improve build performance. By breaking down the build process into smaller stages, Docker can cache the intermediate images and reuse them if the source code or dependencies haven't changed. This can lead to faster builds and shorter development cycles. [Read about docker best practices here](BEST-PRACTICES.md)
269
+
In addition to reducing image size, multi-stage builds can also improve build performance. By breaking down the build process into smaller stages, Docker can cache the intermediate images and reuse them if the source code or dependencies haven't changed. This can lead to faster builds and shorter development cycles. [Read about docker best practices here](docker/Notes/BEST-PRACTICES.md)
-**Dockerfile Instructions:** Every command or instruction in a Dockerfile, such as `FROM`, `RUN`, `COPY`, `ADD`, `WORKDIR`, `EXPOSE`, `ENV`, `VOLUME`, `USER`, `ARG`, `ONBUILD`, `STOPSIGNAL`, `HEALTHCHECK`, `SHELL`, and `CMD`, contributes to the image's layers or metadata.
296
+
-**Filesystem-modifying instructions:** Instructions like `RUN`, `COPY`, and `ADD` create new layers that capture the changes made to the image's filesystem. For example, `RUN apt-get update` would create a layer containing the updated package lists.
297
+
-**Metadata instructions:** Instructions like `EXPOSE`, `ENV`, `LABEL`, `ENTRYPOINT`, and `CMD` don't directly modify the filesystem but add metadata to the image, which is also associated with a layer.
298
+
-**Base Image:** The `FROM` instruction in a Dockerfile specifies a base image, which itself is composed of a stack of existing layers. These base image layers form the foundation upon which your custom layers are built.
299
+
300
+
-**Caching:** Docker leverages layer caching during the build process. If an instruction and its inputs haven't changed since a previous build, Docker can reuse the existing cached layer, making builds faster and more efficient. **A change in one layer, however, will trigger the recreation of that layer and all subsequent layers**.
301
+
302
+
303
+
##### Persistent Data with volumes
304
+
305
+
Docker uses volumes/mounts to persist data beyond container lifecycles. Files written to a volume are saved outside the container, even after deletion.
306
+
283
307
When it comes to storing persistent docker container data , we have three options **Volumes**, **Bind Mounts** and **Tmpfs mounts**
284
308
285
309
**Volumes** : Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. A bind mount uses the host file system, but _Docker volume are native to Docker_.
@@ -425,7 +449,7 @@ $ docker run --volumes-from 4920 \
425
449
**Note** : `--volumes-from`can be use in order to Back up, restore, or migrate data volumes.
426
450
In practice `--volumes-from` is usually used to link volumes between running containers (volume data migration).
427
451
428
-
**Note 2** : Dealing with file permissions with docker volumes can be confusing , (between the host and the container), you can read more about such topic in _docker best practices_ notes [here](BEST-PRACTICES.MD)
452
+
**Note 2** : Dealing with file permissions with docker volumes can be confusing , (between the host and the container), you can read more about such topic in _docker best practices_ notes [here](docker/Notes/BEST-PRACTICES.md)
0 commit comments