Skip to content

Commit 4c3f040

Browse files
update ToC
1 parent c3f61cb commit 4c3f040

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-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: 30 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

@@ -26,6 +35,7 @@ This repository containes a complete _**set**_ of DOCKER NOTES organized as foll
2635
- **[Docker Logs Rotation Configuration](#docker-logs-rotation-configuration)**
2736
- **[Volumes](#volumes-card_file_box)**
2837
- **[The Docker File System](#the-docker-file-system)**
38+
- **[Persistent data with volumes](#[persistent-data-with-volumes)**
2939
- **[Creating and managing a volume](#creating-and-managing-a-volume)**
3040
- **[Usage](#usage)**
3141
- **[Starting a Container with a Volume](#starting-a-container-with-a-volume)**
@@ -58,7 +68,7 @@ $ docker info #Display system-wide information
5868
## Images :framed_picture:
5969
Images are read-only templates containing instructions for creating a container. A Docker image creates containers to run on the Docker platform.
6070
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)
71+
[discover-docker-images-and-containers-concepts-here](docker/Notes/ARCHITECTURE.md)
6272
##### Download an image from a registry (Such as Docker Hub)
6373
```bash
6474
$ docker pull image
@@ -121,7 +131,7 @@ $ docker image inspect [ID/NAME] #Display detailed information on one or more i
121131

122132
## Containers :ship:
123133
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)
134+
[discover-docker-images-and-containers-concepts-here](docker/Notes/ARCHITECTURE.md)
125135
##### Create and run a new container from an image
126136
```bash
127137
docker run --name NAME --rm -itd -p PORTS --net=<custom_net> --ip=IP image COMMAND
@@ -280,6 +290,20 @@ So, any file change inside the container creates a working copy in the read-writ
280290
<img src="https://www.baeldung.com/wp-content/uploads/2021/01/layers.png"/>
281291
</p>
282292

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

285309
**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 \
425449
**Note** : `--volumes-from`can be use in order to Back up, restore, or migrate data volumes.
426450
In practice `--volumes-from` is usually used to link volumes between running containers (volume data migration).
427451

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

430454
## Networking :earth_africa:
431455

0 commit comments

Comments
 (0)