Skip to content

Commit b632dff

Browse files
volumes : How layers are created --> dockerfile instructions
1 parent c3f61cb commit b632dff

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

DOCKERFILE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ In the example above, each instruction creates one layer:
6565
- `RUN` builds your application with `make`.
6666
- `CMD` specifies what command to run within the container.
6767

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) ).
6969

7070

7171
## Dockerfile Instructions Reference
@@ -266,7 +266,7 @@ _Multi-stage builds_ allow us to create a Dockerfile that defines multiple stag
266266

267267
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.
268268

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)
270270

271271
##### Use multi-stage builds
272272

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# Docker Notes
2+
3+
```
4+
____ _
5+
| _ \ ___ ___| | _____ _ __
6+
| | | |/ _ \ / __| |/ / _ \ '__|
7+
| |_| | (_) | (__| < __/ |
8+
|____/ \___/ \___|_|\_\___|_|
9+
10+
```
211
A cheat-sheets and quick but relatively-detailed reference guide for _docker CLI_ commands and some of docker concepts
312

413
This repository containes a complete _**set**_ of DOCKER NOTES organized as follow:
514

6-
- [Docker Architecture](ARCHITECTURE.md)
7-
- [Docker CLI ](README.md) (_current file_)
15+
- [Docker Architecture](docker/Notes/ARCHITECTURE.md)
16+
- [Docker CLI ](docker/Notes/README.md) (_current file_)
817
- [Dockerfile](DOCKERFILE.md)
918
- [Docker Compose](DOCKER-COMPOSE.md)
10-
- [Docker Best Practices](BEST-PRACTICES.md)
19+
- [Docker Best Practices](docker/Notes/BEST-PRACTICES.md)
1120

1221
# Table Of Contents
1322

@@ -58,7 +67,7 @@ $ docker info #Display system-wide information
5867
## Images :framed_picture:
5968
Images are read-only templates containing instructions for creating a container. A Docker image creates containers to run on the Docker platform.
6069
Think of an image like a blueprint or snapshot of what will be in a container when it runs.
61-
[discover-docker-images-and-containers-concepts-here](ARCHITECTURE.md)
70+
[discover-docker-images-and-containers-concepts-here](docker/Notes/ARCHITECTURE.md)
6271
##### Download an image from a registry (Such as Docker Hub)
6372
```bash
6473
$ docker pull image
@@ -121,7 +130,7 @@ $ docker image inspect [ID/NAME] #Display detailed information on one or more i
121130

122131
## Containers :ship:
123132
A container is an isolated place where an application runs without affecting the rest of the system and without the system impacting the application.
124-
[discover-docker-images-and-containers-concepts-here](ARCHITECTURE.md)
133+
[discover-docker-images-and-containers-concepts-here](docker/Notes/ARCHITECTURE.md)
125134
##### Create and run a new container from an image
126135
```bash
127136
docker run --name NAME --rm -itd -p PORTS --net=<custom_net> --ip=IP image COMMAND
@@ -280,6 +289,12 @@ So, any file change inside the container creates a working copy in the read-writ
280289
<img src="https://www.baeldung.com/wp-content/uploads/2021/01/layers.png"/>
281290
</p>
282291

292+
How layers are created:
293+
294+
- **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.
295+
- **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.
296+
- **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.
297+
283298
When it comes to storing persistent docker container data , we have three options **Volumes**, **Bind Mounts** and **Tmpfs mounts**
284299

285300
**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 +440,7 @@ $ docker run --volumes-from 4920 \
425440
**Note** : `--volumes-from`can be use in order to Back up, restore, or migrate data volumes.
426441
In practice `--volumes-from` is usually used to link volumes between running containers (volume data migration).
427442

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)
443+
**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)
429444

430445
## Networking :earth_africa:
431446

0 commit comments

Comments
 (0)