Home >Operation and Maintenance >Docker >What does docker env mean?

What does docker env mean?

藏色散人
藏色散人Original
2020-05-16 11:37:414919browse

What does docker env mean?

What does docker env mean?

1. The ENV instruction in the Dockerfile is used to define the environment variables of the image. An example is as follows:

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

Description: While defining environment variables, you can reference already defined environment variables.

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

HOME,用户主目录
HOSTNAME,默认容器的主机名
PATH,
TERM,默认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

Note:

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

3. After starting the container, in the container instance, you can use the env command View environment variables

env

Recommended: "docker tutorial"

The above is the detailed content of What does docker env mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn