running a container
docker run -d -P training/webapp python app.py
-d //is for background
-P // map any port inside container to the our host
docker ps -l // details of last container
docker ps -a // details of all containers (also stopped ones)
map ports explicitly
docker run -d -p 5000:5000 <container_image> <command>
how to retrieve ip/ports of a docker container and boot2docker VM
// from boot2docker CMD you can run
boot2docker ip
// to retrieve IP of the boot2docker VM
docker port <ID or NAME> <PORT> //show mappings
example on smart method to retrieve ip of a docker running image, in this example an apache2 image and curl command to call that
docker build -f apache-dockerfile-ex3 -t apache-ex3 .
cid=$(docker run -itd -P apache-ex3)
nid=$(docker inspect --format '{{.NetworkSettings.IPAddress}}' $cid)
curl $nid
other commands
docker images // show current images
docker kill $(docker ps -q) // kill all running docker containers
docker rm $(docker ps -aq) // remove all containers