Listing all tcp ports being used (for listening) can be seen with:
netstat -lnt
Looking up what is using a single port can be done with a netstat and grep, or if you have lsof installed:
sudo lsof -i :80 # shows the process using port 80
Starting a docker container on a random available port mapped to port 80 inside the container:
docker run -p 80 -n container_name your_container
Looking up what random port docker used in the above command on the host (this includes what IP interfaces it's attached to, or 0.0.0.0 for all interfaces, which is the default):
docker port container_name 80
sudo netstat -alnp | grep LISTEN
to check and see if the port I want to use is taken or not. If it is taken, can I terminate the program to free it up? if no then I typically move on to another port.