ENV
The Dockerfile instruction that sets an environment variable in the image, visible during the build and in every container.
Values are stored in the image and visible to anyone who can pull it.
In more detail
ENV PORT=8000 bakes a default into the image; docker run -e PORT=9000 overrides it at run time. Anything set with ENV is readable by anyone with the image, so it is for configuration, never for secrets.
Example
ENV PYTHONUNBUFFERED=1Related terms
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
- ARG — The Dockerfile instruction that declares a variable you can set at build time with --build-arg.
- secret — Any value that grants access, such as a password, access token or private key, and must be kept out of code and version control.
Taught in
- Two Environments That Should Have Been Twins — CompTIA Cloud+ (CV0-004) Exam Prep
- An Image That Runs As Root: Security Best Practices — CompTIA Cloud+ (CV0-004) Exam Prep
- Two Reminders, One Booking: Integration And DevOps Tools — CompTIA Cloud+ (CV0-004) Exam Prep
- Install Docker And Verify Your Environment — Docker Architecture & Production Containers
- Build Context, Dockerignore And Your First Dockerfile — Docker Architecture & Production Containers
- ARG, ENV, LABEL, EXPOSE And VOLUME — Docker Architecture & Production Containers
- Multi Stage Builds, Targets And Build Secrets — Docker Architecture & Production Containers
- Authenticate, Tag, Push And Pull From A Registry — Docker Architecture & Production Containers
- Environment, Secret Files And Runtime Restrictions — Docker Architecture & Production Containers
- Define The Service And Database With Compose — Docker Architecture & Production Containers
- Development Overrides, Hot Reloading And Debuggers — Docker Architecture & Production Containers
- Harden And Deliver The Complete Service Stack — Docker Architecture & Production Containers
- From Local Containers To Kubernetes — Docker Architecture & Production Containers
- From docker run To docker service: Replicas, Global Mode And Updates — Docker Certified Associate (DCA) Exam Prep
- Where Do The Tasks Land? Labels, Constraints And Templates — Docker Certified Associate (DCA) Exam Prep
- The Same Shop On Kubernetes: Pods, Services And Storage For The DCA — Docker Certified Associate (DCA) Exam Prep
- Orchestration Sprint: Eight Calls In Eight Minutes — Docker Certified Associate (DCA) Exam Prep
- Twelve Lines, Ten Warnings: Dockerfile Instructions And hadolint — Docker Certified Associate (DCA) Exam Prep
- One Edited File, Six Rebuilt Steps: Layers, Cache And Flat Images — Docker Certified Associate (DCA) Exam Prep
- Who Let Femi In? UCP Roles, Grants, LDAP And Client Bundles — Docker Certified Associate (DCA) Exam Prep
- Security Sprint: Eight Questions On Defaults, Trust And Access — Docker Certified Associate (DCA) Exam Prep