Docker
About Docker

Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first released in 2013 and is developed by Docker, Inc. (Wikipedia)

You can read more about Docker and why to use it from https://www.knowledgehut.com/blog/devops/why-use-docker.

Docker Images and Containers

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Docker Dektop

In order to use Docker, you will need Docker Engine or Docker Desktop. Docker Desktop is a graphical tool which makes it easy to start and stop Containers.

You can download the installation files of Docker Desktop from https://docs.docker.com/engine/install/.

In Windows you will need to install also WSL in order to run Docker Desktop. You can find the instructions for installing WSL (wsl2) from https://learn.microsoft.com/en-us/windows/wsl/install.

Dockerfile

Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. You can read more about Dockerfile from https://docs.docker.com/engine/reference/builder/

.dockerignore

The purpose of the .dockerignore file is to specify which files and directories should be excluded from the Docker context when building an image. It serves a similar function to the .gitignore file used in version control systems like Git.

Here are the main reasons for using .dockerignore:

  1. Efficiency: Including unnecessary files and directories in the Docker build context can slow down the image build process. By specifying these files in .dockerignore, you can speed up the build process by excluding them.
  2. Security: Certain files, such as sensitive data like passwords, keys, or credentials, should not be included in Docker images. The .dockerignore file helps prevent these sensitive files from being inadvertently included in the image.
  3. Reducing Image Size: Excluding unnecessary files and directories from the Docker context can help reduce the size of the resulting Docker image. Smaller images are faster to transfer and deploy, which can be beneficial in various deployment scenarios.
  4. Clarity and Maintainability: Having a clear and well-defined .dockerignore file helps maintain the cleanliness of your Docker context and makes it easier for developers to understand which files are included and excluded from the image build process.

Docker Compose

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration. You can read more about it from https://docs.docker.com/compose/

Here are the commands that you will need

  • docker-compose up -d : create the image and run it inside the container
  • docker-compose down -v : stop the container and remove the Container
  • docker-compose down --rmi all : stop the container and remove the Container and Image(s)
You can find more commands from https://docs.docker.com/engine/reference/commandline/compose_up/

Docker commands

You can make allmost everything you need with Docker Desktop. But you can also use command line. Here are some of the commands, you might found usefull.

  • docker ps : list of running containers
  • docker inspect container_name : details about chosen container
  • docker exec -it container_name bash : open terminal to chosen container
  • docker stop container_name : stop chosen container
  • docker start container_name : start chosen container
You will find more commands from https://docs.docker.com/engine/reference/commandline/docker/

Kubernetes

Kubernetes is an open source orchestration system for automating the management, placement, scaling and routing of containers that has become popular with developers and IT operations teams in recent years.

You can read more about Kubernetes from https://www.docker.com/products/kubernetes/



Toggle Menu