Chapter

Best practices

Make your images smaller, faster and safer with a few proven habits.

Docker Basics 3 Lessons from courses

About this chapter

You can now build and run real apps. This final chapter shares the habits that keep your images lean and secure in production.

Lessons from courses

  1. 1 Smaller images Reduce Docker image size with slim and alpine base images, combined-and-cleaned RUN steps, and a good .dockerignore file.
  2. 2 Multi-stage builds Use Docker multi-stage builds to compile or install in one stage and ship only the result in a small final image with a second FROM.
  3. 3 Security basics Simple Docker security best practices: pin image versions, keep secrets out of images, and run containers as a non-root user with USER.
Docker Basics Go to course