<p>@goulashsoup has good advice...
so, if you mean, how to inspect environment variables in a running container, then do:</p>
<pre><code>docker exec -u root $CONTAINER_ID sh -c &quot;env | sort&quot;
</code></pre>

CC BY-SA 4.0
2024-06-25T13:10:35.263Z
okay got it, thanks
void_meet
CC BY-SA 4.0
2024-06-24T14:30:41.307Z
2024-06-24T14:30:41.307Z
mikequentel
<p>I am unable to get all the env variables even after the <code>docker inspect &lt;container_id&gt;</code> command it just shows only this much when I inspected the mongo:4 image.</p>
<pre><code>                &quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;,
                &quot;GOSU_VERSION=1.17&quot;,
                &quot;JSYAML_VERSION=3.13.1&quot;,
                &quot;MONGO_PACKAGE=mongodb-org&quot;,
                &quot;MONGO_REPO=repo.mongodb.org&quot;,
                &quot;MONGO_MAJOR=4.4&quot;,
                &quot;MONGO_VERSION=4.4.29&quot;,
                &quot;HOME=/data/db&quot;],```
so how to get all the env variables available for the particular image? 
</code></pre>

CC BY-SA 4.0
2024-06-24T12:03:17.793Z
Do you strictly need them before creating a container? Otherwise you could create a container and run `env` on it...
goulashsoup
CC BY-SA 4.0
2024-06-25T13:10:10.150Z
Guess that will help
void_meet
<docker><environment-variables><mongodb>
How to get all the env variables of any docker image?
void_meet
# How to get all the env variables of any docker image?

(Asked by: username_0 on 2024-06-24)

I am unable to get all the env variables even after the docker inspect  command it just shows only this much when I inspected the mongo:4 image.
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "GOSU_VERSION=1.17",
                "JSYAML_VERSION=3.13.1",
                "MONGO_PACKAGE=mongodb-org",
                "MONGO_REPO=repo.mongodb.org",
                "MONGO_MAJOR=4.4",
                "MONGO_VERSION=4.4.29",
                "HOME=/data/db"],```
so how to get all the env variables available for the particular image?

**Tags:** docker, environment-variables, mongodb

> **Comments:**
> **username_1**: Do you strictly need them before creating a container? Otherwise you could create a container and run `env` on it...  
> **username_0**: Guess that will help  

---

## 1 answers

### Answer by username_2 on 2024-06-24. Score: 1

@username_1 has good advice...
so, if you mean, how to inspect environment variables in a running container, then do:
docker exec -u root $CONTAINER_ID sh -c "env | sort"

> **Comments:**
> **username_0**: okay got it, thanks  

---

