|
1 | 1 | # Docker Notes |
| 2 | + |
| 3 | +``` |
| 4 | + ____ _ |
| 5 | + | _ \ ___ ___| | _____ _ __ |
| 6 | + | | | |/ _ \ / __| |/ / _ \ '__| |
| 7 | + | |_| | (_) | (__| < __/ | |
| 8 | + |____/ \___/ \___|_|\_\___|_| |
| 9 | + |
| 10 | +``` |
2 | 11 | A cheat-sheets and quick but relatively-detailed reference guide for _docker CLI_ commands and some of docker concepts |
3 | 12 |
|
4 | 13 | This repository containes a complete _**set**_ of DOCKER NOTES organized as follow: |
5 | 14 |
|
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_) |
8 | 17 | - [Dockerfile](DOCKERFILE.md) |
9 | 18 | - [Docker Compose](DOCKER-COMPOSE.md) |
10 | | -- [Docker Best Practices](BEST-PRACTICES.md) |
| 19 | +- [Docker Best Practices](docker/Notes/BEST-PRACTICES.md) |
11 | 20 |
|
12 | 21 | # Table Of Contents |
13 | 22 |
|
@@ -58,7 +67,7 @@ $ docker info #Display system-wide information |
58 | 67 | ## Images :framed_picture: |
59 | 68 | Images are read-only templates containing instructions for creating a container. A Docker image creates containers to run on the Docker platform. |
60 | 69 | 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) |
62 | 71 | ##### Download an image from a registry (Such as Docker Hub) |
63 | 72 | ```bash |
64 | 73 | $ docker pull image |
@@ -121,7 +130,7 @@ $ docker image inspect [ID/NAME] #Display detailed information on one or more i |
121 | 130 |
|
122 | 131 | ## Containers :ship: |
123 | 132 | 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) |
125 | 134 | ##### Create and run a new container from an image |
126 | 135 | ```bash |
127 | 136 | 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 |
280 | 289 | <img src="https://www.baeldung.com/wp-content/uploads/2021/01/layers.png"/> |
281 | 290 | </p> |
282 | 291 |
|
| 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 | + |
283 | 298 | When it comes to storing persistent docker container data , we have three options **Volumes**, **Bind Mounts** and **Tmpfs mounts** |
284 | 299 |
|
285 | 300 | **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 \ |
425 | 440 | **Note** : `--volumes-from`can be use in order to Back up, restore, or migrate data volumes. |
426 | 441 | In practice `--volumes-from` is usually used to link volumes between running containers (volume data migration). |
427 | 442 |
|
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) |
429 | 444 |
|
430 | 445 | ## Networking :earth_africa: |
431 | 446 |
|
|
0 commit comments