docker container practice

ocker run -d -p 80:5000 training/webapp python app.py
This would map port 5000 inside our container to port 80 on our local host. You might be asking about now: why wouldn’t we just want to always use 1:1 port mappings in Docker containers rather than mapping to high ports? Well 1:1 mappings have the constraint of only being able to map one of each port on your local host. Let’s say you want to test two Python applications: both bound to port 5000 inside their own containers. Without Docker’s port mapping you could only access one at a time on the Docker host.

Note: If you have used the boot2docker virtual machine on OS X, Windows or Linux, you’ll need to get the IP of the virtual host instead of using localhost. You can do this by running the following outside of the boot2docker shell (i.e., from your comment line or terminal application).
$ boot2docker ip
The VM's Host only interface IP address is: 192.168.59.103
In this case you’d browse to http://192.168.59.103:49155 for the above example.

No comments:

Post a Comment