Containers: Docker, Compose and Swarm

Intermediate

The build context

Building the accounts service sends 420 MB to Docker every time, the container crashes on the server with "invalid ELF header", and a security scan just found the production .env file inside the image. Fix the build context.

The folder accounts/ comes from a developer's Mac: it holds .git, a node_modules installed on macOS and the .env used on the server. The test builds accounts/, measures the context, runs the image with --env-file accounts/.env and checks every image for secrets.

What your server must hold

  • Build context sent < 5 MB
  • No secret inside an image
  • Availability ≥ 99 %

What you will master