Docker is a set of the platform as service products that use OS-level virtualisation. It allows to deliver software in packages (containers). These containers are isolated from one another. They also bundles software, libraries, and configuration files. They can communicate with each other through well-defined channels. Wikipedia
Step 1 — Installing Docker Desktop
Step 2 — Drag And Drop The Start The Installation
As any other Mac software installation we need to drag and drop the docker.app into Applications folder:
Step 3 — Launch The Docker Desktop App
Double click on the docker app to start.
Step 4 — Copy The Command Line and Run into The Terminal
In order to start running the docker image execute on the terminal consol the command bellow:
docker run -d -p 80:80 docker/getting-started
To check the running containers you can run the command bellow in the terminal:
Or also we can look in the docker desktop UI at Containers/Apps tab:
Step 5 — Use Of A Dockerfile
The dockerfile is similar to the makefile in gcc jargon. It is a configuration file with a set of commands to build a customised docker image.
As given in the example hereafter:
RUN apt-get update -y
RUN apt-get install -y python
COPY . /app
CMD python /app/Src/app.py
Each instruction creates one layer:
- FROM creates a layer from the ubuntu:18.04 Docker image.
- COPY adds files from your Docker client’s current directory.
- RUN execute installation command.apt-get install
- CMD specifies what command to run within the container.
To run an image and generate its container:
Step 6 — Use Of A Dockerfile-Compose File
The docker-compose is a yaml file containing the composition of your infrastructure. It defines all links between all services need by your app:
- Python image + postgres image + …
docker-compose.yml looks like this:
command: python manage.py runserver 0.0.0.0:8000
For more information about the Compose file. see to the official docker website.
Compose has commands for managing the whole lifecycle of your application:
- Start, stop, and rebuild services
- View the status of running services
- Stream the log output of running services
- Run a one-off command on a service