Asked  7 Months ago    Answers:  5   Viewed   37 times

As the title says. I need to be able to retrieve the IP address the docker hosts and the portmaps from the host to the container, and doing that inside of the container.


/sbin/ip route|awk '/default/ { print $3 }'

As @MichaelNeale noticed, there is no sense to use this method in Dockerfile (except when we need this IP during build time only), because this IP will be hardcoded during build time.

Tuesday, June 1, 2021
answered 7 Months ago

The docker version is 1.10.1. I want the docker container to have same ip as the host with ports exposed.

When you use --net=host it tells the container to use the hosts networking stack. So you can't expose ports to the host, because it is the host (as far as the network stack is concerned).

docker inspect might not show the expose ports, but if you have an application listening on a port, it will be available as if it were running on the host.

Thursday, July 22, 2021
answered 5 Months ago

Use Socket::ip_address_list.

Socket.ip_address_list #=> Array of AddrInfo
Monday, August 9, 2021
Anders Andersen
answered 4 Months ago

You're already exposing the port internally, so the only other thing I can suggest is to check you are opening the port when launching your image too:

docker run -it -p 5000:5000 <imagename>

This will open port 5000 inside the instance to port 5000 on your local machine, and should then be accessible on or localhost:5000.

You should also ensure that you are accepting any host name within Main() in Program.cs with .UseUrls("http://*:5000/") on your WebHostBuilder.

Friday, August 13, 2021
Philip Weiser
answered 4 Months ago

You need to map a page into the kernel memory as follows:

void * mapping = kmap_atomic(page, KM_USER0);
// work with mapping...
kunmap_atomic(mapping, KM_USER0);

This trick is required as there is a HighMemory concept in Linux (see this link for ex.).

UPD: You can use kmap instead of kmap_atomic in non-atomic contexts.

Monday, October 11, 2021
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :