Docker how to get container information from within the container

0 votes
I would like to make my docker containers aware of their configuration, the same way you can get information about EC2 instances through metadata.

how can I get the external IP of the docker host (other than accessing the EC2 metadata, which is specific to AWS)
Jul 31, 2018 in Docker by Hannah
• 18,570 points
779 views

1 answer to this question.

0 votes

I've found out that the container id can be found in /proc/self/cgroup

So you can get the id with :

cat /proc/self/cgroup | grep -o  -e "docker-.*.scope" | head -n 1 | sed "s/docker-\(.*\).scope/\\1/"
answered Jul 31, 2018 by Kalgi
• 52,360 points

Related Questions In Docker

0 votes
1 answer

How to run a docker command from inside the container?

You must have come across the /var/run/docker.sock file, ...READ MORE

answered Jun 28, 2018 in Docker by Sophie may
• 10,610 points
3,269 views
0 votes
1 answer

How to find a Docker container IP address from the command line?

Hi@akhtar, You can use the docker inspect command ...READ MORE

answered Sep 4, 2020 in Docker by MD
• 95,440 points
3,722 views
0 votes
1 answer

How to connect to the localhost of the machine from the Docker container?

Hi@akhtar, You can use --network="host" in your docker run command. It will ...READ MORE

answered Dec 23, 2020 in Docker by MD
• 95,440 points
11,046 views
0 votes
1 answer

How to obtain the Docker container's IP address from the host?

This can be done by executing the ...READ MORE

answered Jul 17, 2018 in Docker by Sophie may
• 10,610 points
8,611 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,090 points
2,469 views
+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,220 points

edited Oct 16, 2018 by lina 33,013 views
0 votes
1 answer

How to get docker-compose to always re-create containers from fresh images?

The containers are getting recreated to preserve ...READ MORE

answered Jul 27, 2018 in Docker by Kalgi
• 52,360 points
4,403 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP