Dockerfile Cheat Sheet



  1. Dockerfile Cheat Sheet
  2. Docker Compose Command Cheat Sheet
  3. Dockerfile Cheat Sheet Pdf

Dockerfile cheatsheet 1 Dockerfile reference 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.

  1. Docker is an open-source platform that can be used to build, ship, and run applications by packaging software in containers. Docker has a lot of commands and options, and it is very difficult to remember every command. This article provides a cheat sheet of the most commonly used Docker commands.
  2. Docker is an increasingly popular tool designed to make it easier to create, deploy and run applications within a container. We recently published an article – Data Scientist guide for getting started with Docker – which hopefully laid out some of the basics. As we have done in the past with SQL, Python Regular Expressions and many others, we thought it would be useful to have a.

With this post, I wanted to share my latest Docker cheatsheet and explain some basics I founded so useful.

Dockerfile Cheat Sheet

DOWNLOAD THE CHEAT SHEET:

Cheat


What is docker?

'Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating system kernel and therefore use fewer resources than virtual machines.' wikipedia

Docker cheat sheet 2020

Dockerfile Cheat Sheet


Cheat

All this sounds a lot to a virtual machine, so what is the main difference? Containers and virtual machines have similar resource isolation and allocation benefits, but function differently because containers virtualize the operating system instead of hardware. Containers are more portable and efficient.

ContainersVirtual Machines
Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space. Containers take up less space than VMs (container images are typically tens of MBs in size), can handle more applications and require fewer VMs and Operating systems.Virtual machines (VMs) are an abstraction of physical hardware turning one server into many servers. The hypervisor allows multiple VMs to run on a single machine. Each VM includes a full copy of an operating system, the application, necessary binaries and libraries - taking up tens of GBs. VMs can also be slow to boot.

Picture from Docker official website.

How to create a Dockerfile

Docker Compose Command Cheat Sheet

A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

Here you can see an example of a real and working Dockerfile. In this example, we create a container with a small Debian package and Python installed.

Dockerfile Cheat Sheet


How to build and play with the container

Once you have a Dockerfile in the main folder, containerize an application is really easy.

1. Build an image

Dockerfile Cheat Sheet Pdf

The first thing we need to do is to create the image, you can do with this command:

In this case, we use --tag in options to assign a name to the image, once done that docker starts building the image from the Dockerfile. To make sure the image was created you can do:

And you will see a list with all the images created.

2. Run a container

To run a container the first thing to do is create it from the image, to do so we can use this command.

In this case, we use the option -it to run the container on interactive mode with tty active, and we assign a name to this container.

3. Accessing to a running container

Sometimes, we lunch a container but it's running in detached mode so we are not able to interact with it. We can access again to that container by the command exec:

With this command, we are running the process 'bin/bash' inside the running container.

Other references and links

  • More articles like this here: Case Studies
  • Github repository: cheatsheets




Comments are closed.