Docker 🐋#
Wow, you don’t know yet what is Docker? Well, let me introduce you this beautiful containerization tool.
Containers?#
- Container ~= virtual machine
A container is like a virtual machine that runs in background on your computer. It simulates a whole system in the same way.
- Container > virtual machnie
But, a container is faster, better and stronger than a classical VM. Because it is meant to be fast and light-weight.
Images#
Docker uses images to run containers. In short an image is a base container, which will be used by your container – like said – as a base. For example, I want to run an Ubuntu container, my Docker image will be something like:
1FROM ubuntu:latest
2
3RUN apt update
This file is called a Dockerfile, because it produces the corresponding Docker container when built.
When ran, this image will use the latest Ubuntu image in Docker’s database, amd update it.
You can do so much in a Docker image!
Build & run#
Once you made your Dockerfile, you will use it to build your Docker image:
1docker build -t my-image .
-t my-image
: the tag (or name if you want) to give to your image.
: the directory where you put yourDockerfile
You now want to run it!
1docker run my-image
And, voila! Your container is running!
Resources#
docker ps
: list all running containersdocker inspect
: get information about a given containerdocker kill
: kill a running containerdocker images
: list all stored Docker images- https://docs.docker.com/get-started/overview/
- https://putaindecode.io/articles/introduction-a-docker/
- https://docker-curriculum.com/
- Setup your database with Docker