I need to get the containers name, from within the running container in python
i could easily get the container id from inside the container in python with
bashCommand = """head -1 /proc/self/cgroup|cut -d/ -f3"""
output = subprocess.check_output(['bash','-c', bashCommand])
print output
now i need the containername
Just set the Name at runtime like:
docker run --name MYCOOLCONTAINER alpine:latest
Then:
bashCommandName = `echo $NAME`
output = subprocess.check_output(['bash','-c', bashCommandName])
print output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With