0% found this document useful (0 votes)
27 views20 pages

102 Working With Containers - Running A WebApp

This document discusses how to work with Docker containers including launching a web app container with port mapping, checking container status and logs, inspecting containers, copying files to and from containers, renaming and removing containers.

Uploaded by

Ram_1781
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views20 pages

102 Working With Containers - Running A WebApp

This document discusses how to work with Docker containers including launching a web app container with port mapping, checking container status and logs, inspecting containers, copying files to and from containers, renaming and removing containers.

Uploaded by

Ram_1781
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Working with

Containers
Command Reference:
https://gist.github.com/initcron/08108141438895252de8
Objectives

• Learn how to work with containers


• Launching a Web App with existing
image
• Network Port Mapping
• Container Operations e.g. inspecting,
checking stats, file copying, removing etc.
In the last session we created a few
containers running hello world app. We are
now going to look at more practical example.
We will launch a container from an existing
image and start a web application.
Launching Web App
$ docker run -d -P training/webapp
python app.py
port mapping

web app
Checking Status

$ docker ps
Port Mapping

host 32768 5000

container

Adding -P option maps port 5000 to port


49153 on our host
-P == -p 5000
Discovering Port Mapping

$ docker port <container_id>


This port is mapped to the VM
and not to host directly. To find
out the ip of the VM run the
following command (on
win/mac host)

$ docker-machine ip default
Validate

http://docker_machine_ip:port
Checking Logs
$ docker logs <container_id>
Show Process Table
$ docker top <container_id>
Show Run Stats
$ docker stats --no-stream=true
<container_id>
Inspecting Container
$ docker inspect <container_id>
Copy Files to and From
Container

$ touch localfile
$ docker cp localfile <container_id>:/opt/
$ docker cp <container_id>:/opt/webapp .
$ docker diff <container_id>
Rename a Container

$ docker rename <container_id> webapp


$ docker ps
Stopping Container
$ docker stop webapp
$ docker ps -l
Removing Container
$ docker rm webapp
$ docker ps -l
Exercise
• Create/Run a new container and limit its
memory to 300M while launching it.

• Hint: look at docker run --help for options


to control resource utilization e.g.
memory, cpu
Summary
• Launching Containers from pre built
image
• Connecting to Applications, Port Mapping
• Container Operations

You might also like