Installing Docker

Installing Docker on different platforms is a straightforward process. Here are step-by-step instructions for installing Docker on macOS, Linux, and Windows:

Installing Docker on macOS:

Prerequisites:

  • macOS 10.13 (High Sierra) or later.
  • An Intel-based Mac. Docker does not support Apple Silicon (M1) natively at the time of my last knowledge update in September 2021, so for M1 users, you may need additional workarounds like using Rosetta or an emulator.

Installation Steps:

  1. Visit the Docker Desktop for Mac download page: Docker Desktop for Mac
  2. Click the “Download for Mac” button to download the Docker Desktop for Mac installer.
  3. Open the downloaded DMG file and drag the Docker application to your Applications folder.
  4. Launch Docker by searching for “Docker” in your Applications folder or using Spotlight.
  5. Once Docker is running, you should see a Docker icon in your menu bar. Click on it to access Docker settings and manage containers.
  6. Docker is now installed and ready to use on your macOS.

Installing Docker on Linux:

Note: The steps for installing Docker on Linux can vary depending on your distribution. Here, we’ll cover the installation process for Ubuntu, a popular Linux distribution.

Installation Steps (for Ubuntu):

  1. Open a terminal window.
  2. Update the package list on your system:
    sudo apt-get update
  3. Install the necessary packages to allow apt to use a repository over HTTPS and ensure compatibility:
    sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
  4. Download and add the Docker GPG key to your system:
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  5. Add the Docker repository to your APT sources:
    echo "deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  6. Update the package list again:
    sudo apt-get update
  7. Finally, install Docker:
    sudo apt-get install docker-ce docker-ce-cli containerd.io
  8. Start and enable Docker to run on system boot:
    sudo systemctl start docker sudo systemctl enable docker
  9. You can verify the installation by running:
    sudo docker --version

Installing Docker on Windows:

Prerequisites:

  • Windows 10 64-bit: Pro, Enterprise, or Education editions.
  • Hyper-V and Containers Windows features enabled.

Installation Steps:

  1. Visit the Docker Desktop for Windows download page: Docker Desktop for Windows
  2. Click the “Download for Windows” button to download the Docker Desktop for Windows installer.
  3. Run the downloaded installer. If prompted, allow the installer to make changes to your device.
  4. Follow the installation wizard, which includes enabling Hyper-V and Containers features if they are not already enabled.
  5. Once the installation is complete, Docker Desktop for Windows will launch automatically. You should see the Docker icon in your system tray.
  6. Docker is now installed and ready to use on your Windows machine.

Depending on your Linux distribution or specific Windows version, there may be slight variations, so it’s always a good idea to consult the official Docker documentation for the most up-to-date and detailed instructions.

What is Docker

Welcome to the world of Docker, where containerization transforms the way we develop, ship, and manage applications.

In this beginner-friendly post, we’ll embark on a journey to understand the fundamental concepts of Docker, setting up Docker on different platforms, and exploring its real-world applications. By the end of this session, you’ll have a solid grasp of what Docker is and how it can revolutionize your software development process.

Understanding Containerization

Containerization is like magic for software developers. It allows you to package an application and its dependencies into a single unit, known as a container. Think of it as a self-contained box that holds everything your app needs to run smoothly, from libraries to system tools. Containers are lightweight, efficient, and highly portable.

A container is

  • an isolated runtime inside of Linux
  • provides a private space under Linux
  • run under any modern Linux kernel

his container has

  • his own process space
  • his own network interface
  • his own disk space

Run as root (inside the container)

Docker vs. Traditional Virtualization

Before Docker, virtualization was the go-to method for running multiple applications on a single server. However, it had its drawbacks. Virtual machines (VMs) are resource-intensive and slower to start. Docker containers, on the other hand, are much more lightweight, as they share the host OS kernel, making them faster and more efficient.

Use Cases for Docker

Docker is incredibly versatile and finds applications across various industries. It’s used for software development, testing, and production deployments. Whether you’re a developer, system administrator, or data scientist, Docker can streamline your workflow and simplify application management.

Setting up Docker

Installing Docker on Various Platforms

Getting started with Docker is easy, regardless of your operating system. Docker provides installation packages for Windows, macOS, and Linux. It’s a matter of a few clicks or commands to have Docker up and running on your machine.

To install Docker on your machin check this post

Exploring Docker Desktop (for Windows and macOS)

For Windows and macOS users, Docker Desktop is a user-friendly tool that simplifies container management. It provides a graphical interface to manage containers, images, and more. It’s a great starting point for those new to Docker.

Docker Versioning and Compatibility

Docker evolves rapidly, with frequent updates and new features. It’s important to understand Docker’s versioning and compatibility matrix to ensure that your containers work seamlessly across different environments.

Docker terminology

Docker Image, representation of a docker container. For instance like a JAR or WAR.

Docker Container, the runtime of Docker. Basically a deployed and running docker image, the instance of the docker image.

Docker Engine, the code which manages Docker stuff. Creates and runs Docker containers

Docker Editions

Docker Enterprise and Community editions

Docker Enterprise, is a Caas (Container as a Service) platform subscription (payed)

Docker Community is a free Docker edition


Question 1: What is containerization?

a) A process of shipping physical containers with software inside
b) A way to package applications and their dependencies
c) A type of virtual machine
d) A tool for managing servers

Correct answer: b) A way to package applications and their dependencies

Question 2: What is a key advantage of Docker containers over traditional virtual machines?

a) Docker containers are more secure
b) Docker containers are larger in size
c) Docker containers share the host OS kernel
d) Docker containers have a GUI

Correct answer: c) Docker containers share the host OS kernel

Question 3: Which of the following is NOT a common use case for Docker?

a) Simplifying application deployment
b) Creating virtual machines
c) Building and testing applications
d) Scaling applications on-demand

Correct answer: b) Creating virtual machines

Question 4: Which platforms does Docker provide installation packages for?

a) Windows, macOS, Linux
b) Windows only
c) macOS only
d) Linux only

Correct answer: a) Windows, macOS, Linux

Question 5: What is Docker Desktop primarily used for?

a) Creating virtual machines
b) Managing Docker containers and images
c) Writing code
d) Playing games

Correct answer: b) Managing Docker containers and images

Question 6: Why is it essential to be aware of Docker’s versioning and compatibility?

a) To ensure your containers work consistently across environments
b) To track the stock market
c) To play the latest video games
d) To learn about new Docker features

Correct answer: a) To ensure your containers work consistently across environments

What is an API

API (Application Programming Interface) are like user interfaces but targeted to be consumed by other applications rather than humans.

This interface defines a contract between provider and consumer.

A contract is the exact structure of the request and response

A bit of story: API format

First API format were:

  • XML RPC (Remote Procedure Call)
  • XML SOAP (Simple Object Access Protocol)

Problem

But … XML is heavy in terms of network traffic, so you couldn’t have large payloads crossing over from the webserver to the clients.

XML parsing is CPU and memory intensive

REST Json

Because of previous problems a new exchange format started to be used:

Rest (Representational State Transfer) JSON (Javascript Object Notation)

RESTful

REST stands for REpresentational STate, which means a set of attribute that an object/thing/entity has in a certain moment. This state is managed by a backend system

Rest is not a specific technology, is not a standard

An API is restful when the API has been built using the RESTful architectural style and it follows the principles for RESTful APIs.

HTTP is the preferred protocol to use API with

TYPES OF API

REST API Consumer

  • Private or Internal (part of the same organization)
  • Public or External (outside of the organization)
  • Partner (trusted relationship with the organization)

REST API TYPES

  • Private API, for private consumer
  • Public/External API for public/external consumer
  • Parter API, for partner consumer

There is no particular difference in coding or design these different APIs. What it changes is that they need different aspect in the management of Security, documentation, access request and SLA.

API Security

Private API, consumer are internal and so known (trusted developers). So we can use:

  • Basic auth
  • proprietary schemes

For public and partner API it’s not possible to trust developer, So we can use:

  • key/secret
  • OAuth

Documentation

In case of Partner and private API we are in a “controlled environment”, so no formal documentation

In the public API we talk about uncontrolled environment, we don’t know about unformal documentation, so we need to publish the documentation on a developer portal (which is a good practice also for the other types)

Access Request

for private and partner API, because of controlled environment we can ask it through emails of internal ticketing/process

In case of public API, uncontrolled environment, it’s a good idea to have request for access through a developer portal (which is a good practice also for the other types)

SLA Management

SLA stands for Service Level Agreement, and specifies which service to expect from a service provider and which are the conditions.

Because of API are sort of contracts, consumer and provider has to agree on the quality and condition of the service, for instance up time 99%, throughput 20 calls per seconds and support by email