no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | get_docker_container_name_from_within_the_container [16.06.2021 13:01] (current) – created Pascal Suter | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== get docker container name from within the container ====== | ||
+ | i recently needed to know the container' | ||
+ | |||
+ | many solutions you find on the internet suggest to share the docker unix socket or tcp socket to access this information from within the container, but that's extremely dangerous as it allows full control over your docker and therefore over your host system with just a few steps from within the container.. | ||
+ | |||
+ | here is a much simpler and better way i have found: we simply query the embedded DNS from docker :) | ||
+ | |||
+ | host $(host $(hostname) | awk ' | ||
+ | |||
+ | this worked for me :) | ||