Learn Docker, Docker Compose, Multi-Container Projects, Deployment and all about Kubernetes from the ground up! Udemy course Notes
Docker is a container technology: A tool for creating and managing containers
- Container: A standardized unit of software (A package of code and dependencies to run that code)
The same container always yields[produce or provide] the exact same application and execution behavior No matter where or by whom it might be executed.
## Images and Containers
Images are the templates/blueprints for containers
Containers are the running "unit of software" (concrete running instance)
We can create images based on others images
Images are Read Only. The image is a "snapshot" of the latest version of the code when the image was created.
whenever you build an image, Docker caches every instruction result, and when you then rebuild an image, it will use these cached results if there is no need to run an instruction again.
Every instruction into the Dockerfile is a layer. The CMD instruction is a layer that will only exist when the container is running.
The container uses the code stored into the image, the container doesn't create a new copy of the code
If you try to remove an image while a container is using that image, you'll see an erro like this:
nodejs-app-starting-setup|main⚡ ⇒ docker rmi 2e6cc7c8b0ff
Error response from daemon: conflict: unable to delete 2e6cc7c8b0ff (cannot be forced) - image is being used by running container ded9c8642876
-
start
command on docker start a cointainer that already exist, this command will be executed in dettached mode on the terminal by default. Use the flag-a
to execute it with the attached mode. -
run
command on docker create and run a new container based on an image, this command will be executed in attached mode on the terminal by default. Use the flag-d
to execute it with the dettached mode. -
We could attached our terminal to a running container executing:
docker attach <cointainer-id>