Get the App
SLTechnology News&Howtos  ›  Servers  › 

What do you think of the environment variables of the docker container

Shulou Source: shulou.com Published: 2022-06-01 03:19:12 10月16日 Update

This article shows you how to look at the environment variables of the docker container, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

What do you think of the environment variables of the docker container? Look at the environment variables of the container, and there are different methods under different conditions.

(1) outside the container

Use the command docker exec {containerID} env` to view the environment variables of the container.

The containerID can enter either the container id, the container id abbreviation (the first few characters of the id), or the container name.

(2) in the container

The environment variable of the container is the environment variable of the No.1 process in the container, and you can use the command

Cat / proc/1/environ View

Similarly, the environment variables of other processes in the container can also be passed through the

Cat / proc/ {pid} / environ View

In general, other processes inherit the environment variables of process 1. Like the host, when you switch users in the container, the environment variables are reset.

If we need to look at the environment variables set by ENV, we may do so in the following ways.

Use the docker inspect command to view

# docker inspect OR

Use the docker exec command to view

Docker exec-it OR env

The above is how to view the environment variables of the docker container. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Container variable environment command process content different that is skill method knowledge input same concise concise under host can pass character situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Apple Docker macOS NVidia