Escolar Documentos
Profissional Documentos
Cultura Documentos
Prerequisites
Basic knowledge of how OS works, no need
to be expert
At least 1 virtual machine
cgroups - Wikipedia
cgroups (abbreviated from control groups) is a Linux kernel feature that limits,
accounts for and isolates the resource usage (CPU, memory, disk I/O, network,
etc.) of a collection of processes.
Engineers at Google (primarily Paul Menage and Rohit Seth) started the work
on this feature in 2006, under the name "process containers".[1] In late 2007
the nomenclature changed to "control groups" due to the confusion caused by
multiple meanings of the term "container" in the Linux kernel context, and
control-group functionality merged into kernel version 2.6.24.[2] Since then,
developers have added many new features and controllers, such as support for
kernfs,[3] firewalling,[4] and unified hierarchy.[5]
Quiz - Containers
What are the benefits of using container
instead of VM?
No need for hypervisor
No need for operating system
No physical hardware
No need for priveleged user
No. Its uselles.
Quiz - Containers
What are the benefits of using container
instead of VM?
No need for hypervisor
No need for operating system
No physical hardware
No need for priveleged user
No. Its uselles.
Quiz - Containers
I create process with PID=1234 in container. What PID will
be on host OS?
a. the same as in container: PID=1234
b. on host there will be PID=4321 that maps to PID=1234
in container
c. it wont be created in container. Actually container
creates it on host.
d. there will be no pid on host. PID=1234 is the child
process in container
Quiz - Containers
I create process with PID=1234 in container. What PID will
be on host OS?
a. the same as in container: PID=1234
b. on host there will be PID=4321 that maps to PID=1234
in container
c. it wont be created in container. Actually container
creates it on host.
d. there will be no pid on host. PID=1234 is the child
process in container
Quiz - Containers
What are the main components of namespaces?
a. uts, ipc, pid, network, user, mount
b. user, pid, mount, filesystem, application, io
c. pid, os, hardware, user, internet, filesystem
d. mount, hardware, network, user, pid, cgroup
Quiz - Containers
What are the main components of namespaces?
a. uts, ipc, pid, network, user, mount
b. user, pid, mount, filesystem, application, io
c. pid, os, hardware, user, internet, filesystem
d. mount, hardware, network, user, pid, cgroup
Quiz - Containers
What should i do to run application with unprivileged user in
container?
a. change the owner to current user and run it
b. login as sudo and run the application
c. enter the container and run it
d. login as sudo then chown the application then run it
Quiz - Containers
What should i do to run application with unprivileged user in
container?
a. change the owner to current user and run it
b. login as sudo and run the application
c. enter the container and run it
d. login as sudo then chown the application then run it
Quiz - Docker
What is the difference between images and containers?
a. containers consist of binary files, images consist of user app files
b. containers run only once, whereas images run multiple times
c. containers pulled from dockerhub, whereas images stores locally
d. images consist of instructions and user files, whereas containers
only runtime environment for user process
Quiz - Docker
What is the difference between images and containers?
a. containers consist of binary files, images consist of user app files
b. containers run only once, whereas images run multiple times
c. containers pulled from dockerhub, whereas images stores locally
d. images consist of instructions and user files, whereas containers
only runtime environment for user process
Quiz - Docker
What will be the result of the following instructions?
docker run -it my-image /bin/bash # lets say it returns ID 123...
echo Sample text | cat > SampleText.txt
exit
docker cp 123:/root/SampleText.txt ./
a. will copy SampleText.txt to current directory
b. will copy data from the current directory to /root/SampleText.txt inside container
c. prints to screen Sample text and copies SampleText.txt to current directory on docker host
d. does nothing. Terminates with error
Quiz - Docker
What will be the result of the following instructions?
docker run -it my-image /bin/bash # lets say it returns ID 123...
echo Sample text | cat > SampleText.txt
exit
docker cp 123:/root/SampleText.txt ./
a. will copy SampleText.txt to current directory
b. will copy data from the current directory to /root/SampleText.txt inside container
c. prints to screen Sample text and copies SampleText.txt to current directory on docker host
d. does nothing. Terminates with error
Quiz - Docker
What will be the result of the following instructions?
docker run -d my-image /bin/bash echo Sample text | cat > SampleText.txt
# lets say returns id 123...
docker run -d my-image /bin/bash ping 8.8.8.8
docker cp 123:/root/SampleText.txt ./
a. will copy SampleText.txt to current directory
b. will copy data from the current directory to /root/SampleText.txt inside container
c. prints to screen Sample text and copies SampleText.txt to current directory on docker host
d. does nothing. Terminates with error
Quiz - Docker
What will be the result of the following instructions?
docker run -d my-image /bin/bash echo Sample text | cat > SampleText.txt
# lets say returns id 123...
docker run -d my-image /bin/bash ping 8.8.8.8
docker cp 123:/root/SampleText.txt ./
a. will copy SampleText.txt to current directory
b. will copy data from the current directory to /root/SampleText.txt inside container
c. prints to screen Sample text and copies SampleText.txt to current directory on docker host
d. does nothing. Terminates with error
Docker Workflow 1
1)
2)
3)
Build as docker:
FROM python:2-onbuild
EXPOSE 8000
CMD [gunicorn, -c, gunicorn_config.py, flask-example:app]
Docker Workflow 2
Download file from curl -L -O http://github.com/atbaker/django-example/archive/master.zip
Build as docker:
FROM python:2.7-onbuild
EXPOSE 8000
CMD [gunicorn, -c, gunicorn_config.py, --chdr, django-example, wsgi:application]
docker run --name postgres -d postgres:9.3
docker run --name memcached -d atbaker/memcached-verbose
docker run --name django -d -p 8000:8000 --link postgres:db --link memcached:cache django-example
docker run --name django --link postgres:db --link memcached:cache django-example python django/example/manage.py
migrate
Useful resources
https://docs.docker.com/ - official docs from Docker
https://docs.docker.com/compose/ - official docs about Docker
Compose
https://docs.docker.com/docker/introduction/understanding-docker/ Docker architecture
https://linuxcontainers.org/ - WiKi about Linux Containers (LXC)
https://lwn.net/Articles/531114/ - Linux namespaces overview
https://lwn.net/Articles/532748/ - Linux PID namespaces