Detailed explanation of the specific use of the ENV instruction in Dockerfile

Detailed explanation of the specific use of the ENV instruction in Dockerfile

1. The ENV instruction in the Dockerfile is used to define the environment variables of the image. Here is an example:

RUN set -ex && apt-get update && apt-get install -y iputils-ping
ENV PATH /usr/local/bin:$PATH
ENV LANG C.UTF-8
ENV TERM xterm
ENV PYTHON_VERSION 3.5.3
ENV name1=ping name2=on_ip
CMD $name1 $name2

Note: When defining environment variables, you can reference already defined environment variables.

In the ENV directive, you can directly reference the following environment variables:

  • HOME, user home directory
  • HOSTNAME, the default container hostname
  • PATH,
  • TERM, default xterm

2. Due to the hierarchical file system of the image, the environment variables defined by ENV can only be applied in subsequent layers. The example is as follows:

ENV abc=hello
ENV abc=bye def=$abc
ENV ghi=$abc

illustrate:

In the above definition, def = hello, ghi = bye

3. After starting the container, you can view the environment variables in the container instance through the env command

env

Reference Links:

https://docs.docker.com/engine/reference/builder/

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of CMD and ENTRYPOINT commands in Dockerfile
  • How to write the best Dockerfile
  • Detailed explanation of COPY and ADD commands in Dockerfile
  • A detailed introduction to the Dockerfile image building file and related commands in Docker
  • Detailed explanation of using Dockerfile to build MySQL image and implement data initialization and permission setting
  • Dockerfile usage examples
  • Dockerfile to create the official Tomcat image and detailed explanation of image usage
  • Summary of common commands in Dockerfile
  • How to deploy SpringBoot project using Dockerfile
  • How to use Dockerfile to create a mirror of the Java runtime environment
  • How to create your own image using Dockerfile
  • Introduction to Dockerfile instructions ADD and COPY
  • Detailed explanation of multi-stage (multi-stage build) in Dockerfile
  • Docker Basics: Detailed Explanation of Dockerfile Commands
  • How to deploy nodejs service using Dockerfile
  • Dockerfile instructions explained
  • A brief introduction to the Dockerfile instruction VOLUME
  • Dockerfile simple introduction

<<:  Problems encountered when uploading images using axios in Vue

>>:  How to install mysql5.7.24 binary version on Centos 7 and how to solve it

Recommend

How to build lnmp environment in docker

Create a project directory mkdir php Create the f...

Implementation of docker-compose deployment project based on MySQL8

1. First, create the corresponding folder accordi...

JavaScript Reflection Learning Tips

Table of contents 1. Introduction 2. Interface 3....

Issues with Rancher deployment and importing K8S clusters

Rancher deployment can have three architectures: ...

MySQL detailed explanation of isolation level operation process (cmd)

Read uncommitted example operation process - Read...

CSS to achieve Cyberpunk 2077 style visual effects in a few steps

background Before starting the article, let’s bri...

Website redesign is a difficult task for every family

<br />Every family has its own problems, and...

How to use vue.js to implement drag and drop function

Preface Adding drag and drop functionality is a g...

SVG button example code based on CSS animation

The specific code is as follows: <a href="...

Introduction to general_log log knowledge points in MySQL

The following operation demonstrations are all ba...

64-bit CentOs7 source code installation mysql-5.6.35 process sharing

First install the dependent packages to avoid pro...

Zabbix WEB monitoring implementation process diagram

Take zabbix's own WEB interface as an example...

Detailed tutorial on deploying Hadoop cluster using Docker

Recently, I want to build a hadoop test cluster i...

Rules for registration form design

I finished reading "Patterns for Sign Up &...