2

In a machine that runs a docker container I attach to the running container: docker exec -it SHA1 /bin/bash How can I see the environment variables of the process running in the container? I see that if I try to cat /proc/$pid/environ I get a permission error despite the fact that I am root. Why do I get the permission error? Is there another way to check the environment variables?

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Jim
  • 1,353
  • 4
  • 19
  • 27

1 Answers1

2

An alternative to cat /proc/$pid/environ is using ps e -p $pid

see https://unix.stackexchange.com/a/29132/193945

As for the permission-error, without a Dockerfileit can be hard to tell. Are you using SELinux ? How did you start the container ?

Have you tried exec with --privileged ?

invad0r
  • 220
  • 1
  • 8