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: README.md
+14-2Lines changed: 14 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2522,11 +2522,13 @@ Docker daemon redirects output from container to Docker CLI which redirects it t
2522
2522
2523
2523
<details>
2524
2524
<summary>How do you run a container?</summary><br><b>
2525
+
2525
2526
docker run
2526
2527
</b></details>
2527
2528
2528
2529
<details>
2529
2530
<summary>What `docker commit` does?. When will you use it?</summary><br><b>
2531
+
2530
2532
Create a new image from a container’s changes
2531
2533
</b></details>
2532
2534
@@ -2551,6 +2553,7 @@ Create a new image from a container’s changes
2551
2553
2552
2554
<details>
2553
2555
<summary>How do you remove old, non running, containers?</summary><br><b>
2556
+
2554
2557
1. To remove one or more Docker images use the docker container rm command followed by the ID of the containers you want to remove.
2555
2558
2. The docker system prune command will remove all stopped containers, all dangling images, and all unused networks
2556
2559
3. docker rm $(docker ps -a -q) - This command will delete all stopped containers. The command docker ps -a -q will return all existing container IDs and pass them to the rm command which will delete them. Any running containers will not be deleted.
@@ -2560,18 +2563,21 @@ Create a new image from a container’s changes
2560
2563
2561
2564
<details>
2562
2565
<summary>What is Dockerfile</summary><br><b>
2566
+
2563
2567
Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.
2564
2568
</b></details>
2565
2569
2566
2570
<details>
2567
2571
<summary>What is the difference between ADD and COPY in Dockerfile?</summary><br><b>
2572
+
2568
2573
COPY takes in a src and destination. It only lets you copy in a local file or directory from your host (the machine building the Docker image) into the Docker image itself.
2569
2574
ADD lets you do that too, but it also supports 2 other sources. First, you can use a URL instead of a local file / directory. Secondly, you can extract a tar file from the source directly into the destination.
2570
2575
Although ADD and COPY are functionally similar, generally speaking, COPY is preferred. That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious.
2571
2576
</b></details>
2572
2577
2573
2578
<details>
2574
2579
<summary>What is the difference between CMD and RUN in Dockerfile?</summary><br><b>
2580
+
2575
2581
RUN lets you execute commands inside of your Docker image. These commands get executed once at build time and get written into your Docker image as a new layer.
2576
2582
CMD is the command the container executes by default when you launch the built image. A Dockerfile can only have one CMD.
2577
2583
You could say that CMD is a Docker run-time operation, meaning it’s not something that gets executed at build time. It happens when you run an image. A running image is called a container.
@@ -2585,8 +2591,8 @@ A common answer to this is to use [hadolint](https://github.com/hadolint/hadolin
2585
2591
2586
2592
<details>
2587
2593
<summary>Explain what is Docker compose and what is it used for</summary><br><b>
2588
-
2589
-
Docker Compose is used for running multi-container applications
2594
+
2595
+
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
2590
2596
</b></details>
2591
2597
2592
2598
<details>
@@ -2610,10 +2616,16 @@ Swarm management which means you can create new swarms in Docker Cloud.
2610
2616
2611
2617
<details>
2612
2618
<summary>Where Docker images are stored?</summary><br><b>
2619
+
In DockerHub
2613
2620
</b></details>
2614
2621
2615
2622
<details>
2616
2623
<summary>Explain image layers</summary><br><b>
2624
+
2625
+
A Docker image is built up from a series of layers. Each layer represents an instruction in the image’s Dockerfile. Each layer except the very last one is read-only.
2626
+
Each layer is only a set of differences from the layer before it. The layers are stacked on top of each other. When you create a new container, you add a new writable layer on top of the underlying layers. This layer is often called the “container layer”. All changes made to the running container, such as writing new files, modifying existing files, and deleting files, are written to this thin writable container layer.
2627
+
The major difference between a container and an image is the top writable layer. All writes to the container that add new or modify existing data are stored in this writable layer. When the container is deleted, the writable layer is also deleted. The underlying image remains unchanged.
2628
+
Because each container has its own writable container layer, and all changes are stored in this container layer, multiple containers can share access to the same underlying image and yet have their own data state.
0 commit comments