{
  "id": 22327619,
  "title": "Stop Running chmod 777 in Dockerfiles: Least-Privilege Linux Permissions & BuildKit --chmod Cheatsheet",
  "url": "https://urgent.news/2026/11/28/stop-running-chmod-777-in-dockerfiles-least-privilege-linux",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-28T08:22:02.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/woojinlim530/stop-running-chmod-777-in-dockerfiles-least-privilege-linux-permissions-buildkit-chmod-5bhh"
  },
  "original_language": null,
  "account": "Running chmod 777 in Dockerfiles poses significant security risks, including granting excessive permissions to all users, breaking CIS Docker Benchmark hardening, allowing compromised subprocesses to overwrite application binaries, and increasing container image size. To address this issue in 2026, a production-safe approach to Linux and Docker file permissions is recommended.\n\nFive production modes for Linux file permissions are outlined, including octal, symbolic, and use case examples. These modes range from read-only for TLS private keys to executable and non-executable permissions for various files and directories. It is crucial never to use 666 (world-writable) or 777 (world-writable) permissions.\n\nTo improve build processes, it is advised to use BuildKit's COPY --chown --chmod command instead of the traditional RUN chmod -R. This approach eliminates the need for duplicate image layers and ensures exact least-privilege permissions on every file. An interactive Chmod & Dockerfile Permission Calculator is available for free to help users toggle permissions and generate ready-to-paste commands.\n\nTry the Free Interactive Chmod & Dockerfile Snippet Generator to streamline your Dockerfile permissions and enhance security in your containerized applications.",
  "summary": "Whenever a containerized app throws EACCES: permission denied in CI or Kubernetes, the fastest \"fix\" people reach for is: RUN chmod -R 777 /app It makes the error disappear—and immediately breaks CIS Docker Benchmark hardening, lets any compromised subprocess overwrite your application binaries, and doubles your container image size because Docker creates a full copy-on-write layer for every…",
  "summary_source": "publisher",
  "key_points": [
    "Running chmod 777 in Dockerfiles poses significant security risks.",
    "Five production modes for Linux file permissions are outlined, avoiding 666 and 777 permissions."
  ],
  "editors_take": "Adopting specific permission modes and BuildKit commands protects applications from compromised subprocesses while reducing container image sizes and improving overall security.",
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}