Just to increase @VonC's answer in the script - currently, if you use the Docker Toolbox on MacOS X, the default VM machine is "default." Thus, the script to display all the exhibits from the container should look like this:
for port in `docker port cassandra | cut -d'-' -f1`; do port_num=`echo ${port} | cut -d'/' -f1` port_type=`echo ${port} | cut -d'/' -f2` echo "Create rule natpf1 for ${port_type} port ${port_num}" VBoxManage controlvm "default" natpf1 "${port_type}-port${port_num},${port_type},,${port_num},,${port_num}" done
If you try to execute several times, to delete an existing rule, add an instruction before creating it:
VBoxManage controlvm "default" natpf1 delete "${port_type}-port${port_num}"
The script assumes that you are already migrating ports from the container to the virtual machine.
docker port cassandra
gives a conclusion, for example:
7000/tcp -> 0.0.0.0:7000
npenkov Jan 12 '16 at 19:50 2016-01-12 19:50
source share