Whale from docker logo

docker


Very quick docker introduction

Think of docker as a way to run multiple isolated operating systems (containers) inside your operating system. Containers act a bit like soap bubbles. They are created. They do something. Poof! and they are gone.

Why use containers ?

Containerization allows for easy separation of concerns and isolation. You can say:

This container will take care of DB only and nothing else

You are able to configure that container the way that is adjusted perfectly to running your DB only. Install only the packages that the DB requires and nothing else. As a result you’re creating a small specialized subsystem. You are not concerned about other services that are required for your application. As Bob Marley once sang:

Likewise you configure your frontend container and every other container your application requires.

Four sentences you need to know about docker in order to survive winter

First of all you need to build the container. After container has been built you can optionally push it into a remote container registry. You can run your containers. Before you run them you can optionally pull the container’s image from the remote source.

Basic commands

Login to Docker Hub

docker login

Login to Container Registry on GitLab

docker login registry.gitlab.com

Build an image

docker build -t registry.gitlab.com/USERNAME/PROJECT_NAME/IMAGE_NAME:v1.0.0 PATH_TO_Dockerfile

View docker images that have been built and pulled

docker images

Remove docker image

docker rmi IMAGE_ID

Push docker image to a remote container registry

docker push registry.gitlab.com/USERNAME/PROJECT_NAME/IMAGE_NAME:v1.0.0

Run docker image

docker run -it registry.gitlab.com/USERNAME/PROJECT_NAME/IMAGE_NAME:v1.0.0

Useful links

Benefits of using docker –  https://apiumhub.com/tech-blog-barcelona/top-benefits-using-docker/

Introduction to docker with WordPress – https://codeable.io/wordpress-developers-intro-docker/