There is a simple command to get an IP of a container
docker inspect < name_of_container >
If you want to use it in configuration scripts you can write the command like this
ABC=$(docker run -d -p 4321 base nc -lk 4321);
docker inspect $ABC
There is a slight issue with though, when you run the inspect command - You will get a lot more things than just the IP address of the container.
To get just the IP address you can use grep :
docker inspect < name_of_container > | grep "IPAddress"
This will give you the IP address of the container only.
Also If you want to become more adept with docker you can check this Docker training course . You will be trained by industry professionals who have years of experience in docker. Or you can check out this Docker Tutorial to get to know more about how to use docker.