Skip to content

juan131/dockerfile-best-practices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Best Practices writing a Dockerfile

This repository is a guide with a set of good practices when writting Dockerfiles.

Using a Node.js application as example, this guide will be a journey from a very basic Dockerfile to make it production ready, describing some of the best practices and common pitfalls that you are likely to encounter when developing Dockerfiles.

Before we start

On this blog post you'll find detailed information about each of the steps we'll do to improve the Dockerfile. Please use it to follow this tutorial.

Note: the blog post was published on February 2019. There are corrections and updates only available on this GitHub repository.

Enable BuilKit

Use BuildKit to build your Docker images. It can improve the performance when building Docker images.

It can be enabled on two different ways:

  • Exporting the DOCKER_BUILDKIT environment variable:
export DOCKER_BUILDKIT=1

TIP: add it to your ~/.bashrc file

{
  "features": {
    "buildkit": true
  }
}

Install a Linter for Dockerfiles on your IDE

A Linter helps you to detect syntax errors on your Dockerfiles and provides you suggestions based on common practices.

There are plugins that provide these functionalities for almost every IDE. Here you have some suggestions:

How to use this tutorial

Starting from the 'master' branch, you'll find a branch with the files to use on each step of the tutorial.

It's only necessary to switch (checkout) to the proper branch. The available branches are:

About

Best Practices writing a Dockerfile

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published