Skip to content

ajtrichards/dockerfile-best-practices

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 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.

Enable BuilKit

Use BuildKit to build your 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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 55.5%
  • Dockerfile 44.5%