The Essential Docker, Dockerfile, and Docker Compose Cheat Sheet

Docker has become an essential tool for every software developer. If you haven’t yet heard about Docker, it’s a free, powerful, and reliable tool for creating and deploying containers, available for Linux, macOS, and Windows. From the official Docker documentation:

“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.”

Image for post

Docker architecture — docker.com

With Docker, developers can forget headaches when trying to deploy their apps. Your application is bundled as an image, and this image is deployed as a container in your server or on the cloud. With Docker Compose, you can even orchestrate the deployment of several services that together constitute an application.

Image for post

Photo by chuttersnap on Unsplash


Docker CLI commands

Docker offers a UI called Docker Dashboard, from where you can do some tasks, but the most usual way to work with Docker is through its CLI, so let’s see here some examples of the most useful and usual commands.

Create and run a container from an image

To create and run a container called “my_beautiful_container” with an official Ubuntu image, we would just use the [docker run](https://docs.docker.com/engine/reference/run/) command:

docker run -d — name my_beautiful_container ubuntu  ## run the container as a background process

docker run -it — name my_beautiful_container ubuntu /bin/bash  ## run the container and launch an interactive shell on it

When using the run command, we can also map a container port to a host machine port (very important for web servers) for instance:

docker run -p 1234:80 ubuntu  ## map the port 80 in the container to 1234 in the host machine

By their nature, containers don’t offer data persistence. If we need some data inside our container to be persisted after reboots, we have to use volumes, and that means mounting a host machine folder into the container filesystem:

docker run -v ~/my_folder:/root ubuntu  ## mount the host machine folder ~/my_folder into the /root directory in the container

#docker-compose #devops #programming #docker #containers

What is GEEK

Buddha Community

The Essential Docker, Dockerfile, and Docker Compose Cheat Sheet

The Essential Docker, Dockerfile, and Docker Compose Cheat Sheet

Docker has become an essential tool for every software developer. If you haven’t yet heard about Docker, it’s a free, powerful, and reliable tool for creating and deploying containers, available for Linux, macOS, and Windows. From the official Docker documentation:

“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.”

Image for post

Docker architecture — docker.com

With Docker, developers can forget headaches when trying to deploy their apps. Your application is bundled as an image, and this image is deployed as a container in your server or on the cloud. With Docker Compose, you can even orchestrate the deployment of several services that together constitute an application.

Image for post

Photo by chuttersnap on Unsplash


Docker CLI commands

Docker offers a UI called Docker Dashboard, from where you can do some tasks, but the most usual way to work with Docker is through its CLI, so let’s see here some examples of the most useful and usual commands.

Create and run a container from an image

To create and run a container called “my_beautiful_container” with an official Ubuntu image, we would just use the [docker run](https://docs.docker.com/engine/reference/run/) command:

docker run -d — name my_beautiful_container ubuntu  ## run the container as a background process

docker run -it — name my_beautiful_container ubuntu /bin/bash  ## run the container and launch an interactive shell on it

When using the run command, we can also map a container port to a host machine port (very important for web servers) for instance:

docker run -p 1234:80 ubuntu  ## map the port 80 in the container to 1234 in the host machine

By their nature, containers don’t offer data persistence. If we need some data inside our container to be persisted after reboots, we have to use volumes, and that means mounting a host machine folder into the container filesystem:

docker run -v ~/my_folder:/root ubuntu  ## mount the host machine folder ~/my_folder into the /root directory in the container

#docker-compose #devops #programming #docker #containers

Iliana  Welch

Iliana Welch

1595249460

Docker Explained: Docker Architecture | Docker Registries

Following the second video about Docker basics, in this video, I explain Docker architecture and explain the different building blocks of the docker engine; docker client, API, Docker Daemon. I also explain what a docker registry is and I finish the video with a demo explaining and illustrating how to use Docker hub

In this video lesson you will learn:

  • What is Docker Host
  • What is Docker Engine
  • Learn about Docker Architecture
  • Learn about Docker client and Docker Daemon
  • Docker Hub and Registries
  • Simple demo to understand using images from registries

#docker #docker hub #docker host #docker engine #docker architecture #api

Docker called the Voting App.

In this section, we will learn about Docker Compose, its file, and its commands, using a sample application developed by Docker called the Voting App.

  1. Introduction
  2. Docker File
  3. Basic Docker Commands
  4. Port and Volume Mapping
  5. Docker Networking
  6. Docker Storage
  7. Docker Compose (You are here!)
  8. Deleting Docker Entities

The Voting App is a Flask application written in Python to vote between Cats and Dogs.

Image for post

This vote is then transferred to Redis, which acts as an in-memory DB here. The worker application, written in .NET, then processes this vote and inserts it in the persistent database — the Postgres container here.

Image for post

Finally, the result of the vote is displayed via a web application that is written in NodeJS.

Image for post

Web Application in NodeJS

I highly encourage you to clone this application and play around with it, even if you do not know anything about Docker Compose yet. If you can appreciate the fact that these services are running on 5 different containers you already have your motivation to continue reading.

git clone git@github.com:dockersamples/example-voting-app.git

cd example-voting-app/
docker-compose up

#docker-compose #docker #docker-networking #design-systems #dockerfiles

Run multi-container Docker applications with a single command

What is docker?

Docker is a platform to develop, deploy, and run applications inside independent and isolated environments. These environments are then called containers. This will let the developer run a container on any machine.

Simply docker solves the problem of **‘’It works on my machine’’**.

As you can see, with Docker, there are no more dependency or compilation problems. All you have to do is launch your container, and your application will launch immediately.

If you want to learn more about this excellent platform, the “Get Started” section of Docker Docs is a great place to start.


Let’s move onto the topic.

If your application is containing more than one component (multiple containers), how do you manage such a situation easily? It means you need to run those multiple containers separately. How do you manage their network connectivity, volume binding, port binding, etc. from a central point?

When using Docker widely, the management of several different containers quickly becomes cumbersome.

Image for post

Introducing docker-compose

Docker Compose is a tool that helps us overcome this problem and efficiently handle multiple containers at once. Also used to manage several containers at the same time for the same application.

This tool can become very powerful and allow you to deploy applications with complex architectures very quickly.

Image for post

#containerization #docker-compose #dockerfiles #docker-image #docker

August  Murray

August Murray

1615008840

Top 24 Docker Commands Explained with Examples

In my previous blog post, I have explained in detail how you can Install Docker and Docker-compose on Ubuntu

In this guide, I have explained the Top 24 Docker Commands with examples.

Make sure you have sudo or root privileges to the system.

Docker Commands

  1. The command to check the version of Docker installed.
  2. To look/search for available docker images from the Docker registry.
  3. To pull docker images from the Docker registry.
  4. Listing all the docker images
  5. Creating / Running docker container from Docker image.
  6. To list the actively running docker containers.
  7. To list all the docker containers
  8. To stop a Container
  9. To start a Container
  10. To restart a Docker container
  11. To login to running Docker container
  12. To delete the stopped Docker containers
  13. To delete Docker images from the Local system
  14. To check logs of a running Docker container
  15. Killing docker containers
  16. Log in to Docker Hub registry (hub.docker.com)
  17. Removing docker hub registry login from the system.
  18. Check active resource usage by each containers
  19. Rename a Docker container
  20. To display system wide information of Docker
  21. Inspecting a Docker container
  22. Building docker images from Docker file
  23. Creating new docker images from a Container
  24. Pushing Docker images from Local to Docker registry.

#docker #docker-command #containers #docker-compose #docker-image