

f Dockerfile-insecure-1 -t insecure-app-1 -build-arg NPM_TOKEN=$NPM_TOKEN.

npmrc file from your Dockerfile, it will be saved in your Docker image. I have revoked all npm tokens featured in all screenshots. I also created a companion GitHub repository for this blog post so you can follow along with my examples. The concepts I cover apply to any Dockerfile that uses tokens, passwords, or other secrets though. This blog post focuses on using Docker with Node.js and npm. Finally, I’ll explain how multi-stage builds enable you to securely use. For each scenario, I’ll show how an attacker can exploit it to steal your npm access tokens. In this blog post, I’ll first describe the common ways people use. This enables us to npm install our private packages in earlier build stages without leaking our tokens in the final image. Only the intermediate images and commit history from the last build stage end up in our final Docker image. Multi-stage builds allow us to securely use. In fairness, most of these resources date from before Docker shipped multi-stage builds in Docker v17.05 in May 2017.

npmrc files from intermediate images or npm tokens from the image commit history though. Many of these guides don’t cover how to remove. npmrc files from your Dockerfile after installing private npm packages. Most blog posts, Stack Overflow answers, and documentation recommend you delete. npmrc file contains a token with read/write access to your private npm packages. npmrc files ( npm config files) to download private npm packages.

I recently completed a security audit of Docker images for a project. I recommend reading that post after this one! Building Docker images with private npm packages On February 24th, 2019 I published a follow-up post about using Docker build secrets instead of multi-stage builds. npmrc files in Docker images Jun 25, 2018
