SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
Docker
ao vivo e a cores
Pedro Arthur P. R. Duarte
pedroarthur.jedi@gmail.com
"Na minha máquina
funciona!"
– você?
2
Como assim containers?
3
Implantação de Aplicações
https://www.datadoghq.com/blog/the-docker-monitoring-problem/
4
E por que só agora?
https://en.wikipedia.org/wiki/Docker_(software)
5
Imagens de Software
https://delftswa.github.io/chapters/docker/
6
Principais engines de tempo de execução
http://docker.com/ http://coreos.com/rkt/
7
Execução de Processos em Containers
https://coreos.com/rkt/docs/latest/rkt-vs-other-projects.html
8
Ao vivo!
9
Baixando e executando containers
r2@d2 $ docker pull debian:jessie
jessie: Pulling from library/debian
386a066cd84a: Pull complete
Digest: sha256:c1ce85a0f7126a3b5cbf7c57676b01b37c755b9ff9e2f39ca88181c02b985724
Status: Downloaded newer image for debian:jessie
r1@d2 $ docker run -it debian:jessie /bin/bash
root@c0c4c014d3af:/# ping 4.2.2.2
PING 4.2.2.2 (4.2.2.2): 56 data bytes
64 bytes from 4.2.2.2: icmp_seq=0 ttl=53 time=109.191 ms
--- 4.2.2.2 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 109.191/109.191/109.191/0.000 ms
root@c0c4c014d3af:/# exit 0
r1@d2 $ docker run -t debian:jessie ping -c 1 4.2.2.2
# mostly the same as the previous command
10
Construindo um Container: aplicação
Servidor de Echo
#!/ usr/bin/env python
from twisted.internet.protocol import Protocol , Factory
from twisted.internet import reactor
from twisted.python import log
from sys import stdout
class Echo(Protocol ):
def dataReceived (self , data ):
log.msg("Received", data)
self.transport.write(data)
log. startLogging (stdout)
log.msg("Echo server is starting")
reactor.listenTCP (8000 , Factory. forProtocol (Echo ))
reactor.run ()
11
Construindo um Container: Dockerfile
Arquivo de Descrição do Container
FROM debian:jessie
RUN apt -get update 
&& apt -get install -y python -twisted 
&& apt -get clean
COPY echo_server .py /usr/local/bin
EXPOSE 8000
CMD exec /usr/local/bin/ echo_server .py
12
Construindo um Container: build
r2@d2 $ docker build -t poticon_echo_server:1.0 .
Sending build context to Docker daemon 5.12 kB
Step 1 : FROM debian:jessie
---> 73e72bf822ca
Step 2 : RUN apt-get update && apt-get install -y python-twisted && apt
---> Running in e37b92a3c12b
# a lot of apt-get-related output
---> 6fbd3015ca0c
Removing intermediate container e37b92a3c12b
Step 3 : COPY echo_server.py /usr/local/bin
---> 87add3168ac0
Removing intermediate container 956612405c96
Step 4 : EXPOSE 8000
---> Running in 810fee23449d
---> 70890ad7e011
Removing intermediate container 810fee23449d
Step 5 : CMD exec /usr/local/bin/echo_server.py
---> Running in 65fd3384e5eb
---> 1b46b966c54e
Removing intermediate container 65fd3384e5eb
Successfully built 1b46b966c54e
Executando e Testando nosso container
r2@d2 $ docker run -t --net=host poticon_echo_server:1.0
2016-11-24 12:53:19+0000 [-] Log opened.
2016-11-24 12:53:19+0000 [-] Echo server is starting
2016-11-24 12:53:19+0000 [-] Factory starting on 8000
2016-11-24 12:53:19+0000 [-] Starting factory <twisted.internet.protocol.Factory in
2016-11-24 12:53:28+0000 [Echo,0,127.0.0.1] Received Hi, there!
# at another terminal; ts comes from moreutils
r2@d2 $ nc 127.0.0.1 8000 | ts ’%F %T’
Hi, there!
2016-11-24 12:53:28 Hi, there!
14
Composição de Serviços
r2@d2 $ cat docker-compose.yaml
version: ’2’
services:
redis:
image: redis
postgresql:
image: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=$PG_PASSWORD
r2@d2 $ export PG_PASSWORD=p0t1c0n
r2@d2 $ docker-compose up -d # -d puts them in background
r2@d2 $ docker-compose logs # use -f to follow
r2@d2 $ docker-compose down # mind other commands such as stop and start
15
Por onde continuar?
16
Docker para Desenvolvedores
https://leanpub.com/dockerparadesenvolvedores
17
Links Úteis
Tecnologias de Containers:
– Docker: http://github.com/docker/
– Rkt: http://coreos.com/rkt
Orquestradores de Containers
– CoreOS: http://coreos.com
– Kubernetes: http://github.com/kubernetes
– Swarm: http://docker.com/swarm
18

Mais conteúdo relacionado

Mais procurados

2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 

Mais procurados (20)

nouka inventry manager
nouka inventry managernouka inventry manager
nouka inventry manager
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
agri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertoragri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertor
 
Meetup C++ Floripa - Conan.io
Meetup C++ Floripa - Conan.ioMeetup C++ Floripa - Conan.io
Meetup C++ Floripa - Conan.io
 
Docker deploy
Docker deployDocker deploy
Docker deploy
 
Making environment for_infrastructure_as_code
Making environment for_infrastructure_as_codeMaking environment for_infrastructure_as_code
Making environment for_infrastructure_as_code
 
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
 
Docker in Production: Reality, Not Hype
Docker in Production: Reality, Not HypeDocker in Production: Reality, Not Hype
Docker in Production: Reality, Not Hype
 
CI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOWCI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOW
 
Lviv 2013 d7 vs d8
Lviv 2013   d7 vs d8Lviv 2013   d7 vs d8
Lviv 2013 d7 vs d8
 
nginx + uwsgi emperor + bottle
nginx + uwsgi emperor + bottlenginx + uwsgi emperor + bottle
nginx + uwsgi emperor + bottle
 
Conan a C/C++ Package Manager
Conan a C/C++ Package ManagerConan a C/C++ Package Manager
Conan a C/C++ Package Manager
 
Docker for Java developers at JavaLand
Docker for Java developers at JavaLandDocker for Java developers at JavaLand
Docker for Java developers at JavaLand
 
Simple webapps with nginx, uwsgi emperor and bottle
Simple webapps with nginx, uwsgi emperor and bottleSimple webapps with nginx, uwsgi emperor and bottle
Simple webapps with nginx, uwsgi emperor and bottle
 
Usage Note of PlayCap
Usage Note of PlayCapUsage Note of PlayCap
Usage Note of PlayCap
 
Docker as an every day work tool
Docker as an every day work toolDocker as an every day work tool
Docker as an every day work tool
 
Learn enough Docker to be dangerous
Learn enough Docker to be dangerousLearn enough Docker to be dangerous
Learn enough Docker to be dangerous
 
Dev ops
Dev opsDev ops
Dev ops
 
Usage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP LanguagesUsage Note of Apache Thrift for C++ Java PHP Languages
Usage Note of Apache Thrift for C++ Java PHP Languages
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 

Destaque

NEW ROOTS FINAL COLOR FILE
NEW ROOTS FINAL COLOR FILENEW ROOTS FINAL COLOR FILE
NEW ROOTS FINAL COLOR FILE
Alissa Anderson
 
Blogging & e portfolios PD by Jocelyn Sutherland
Blogging & e portfolios PD by Jocelyn SutherlandBlogging & e portfolios PD by Jocelyn Sutherland
Blogging & e portfolios PD by Jocelyn Sutherland
jocelyns
 

Destaque (19)

Cpgp day02 session 7 - cp-costing of wastes
Cpgp day02 session 7 - cp-costing of wastesCpgp day02 session 7 - cp-costing of wastes
Cpgp day02 session 7 - cp-costing of wastes
 
amplifire2
amplifire2amplifire2
amplifire2
 
amplifire
amplifireamplifire
amplifire
 
Benito lertxundi. ;)
Benito lertxundi. ;)Benito lertxundi. ;)
Benito lertxundi. ;)
 
NEW ROOTS FINAL COLOR FILE
NEW ROOTS FINAL COLOR FILENEW ROOTS FINAL COLOR FILE
NEW ROOTS FINAL COLOR FILE
 
P&P PMO - Folha Informativa
P&P PMO - Folha Informativa P&P PMO - Folha Informativa
P&P PMO - Folha Informativa
 
Blogging & e Portfolios PD by Jocelyn Sutherland
Blogging & e Portfolios PD by Jocelyn SutherlandBlogging & e Portfolios PD by Jocelyn Sutherland
Blogging & e Portfolios PD by Jocelyn Sutherland
 
Izengabea 1
Izengabea 1Izengabea 1
Izengabea 1
 
Analizando mi evolución nancy
Analizando mi evolución nancyAnalizando mi evolución nancy
Analizando mi evolución nancy
 
Documento
DocumentoDocumento
Documento
 
Environmental Impact Assessment FROM CHAKDARA TO MADYAN
Environmental Impact Assessment FROM CHAKDARA TO MADYANEnvironmental Impact Assessment FROM CHAKDARA TO MADYAN
Environmental Impact Assessment FROM CHAKDARA TO MADYAN
 
Power point aec
Power point aecPower point aec
Power point aec
 
[#openIQUII - Workshop] Personal e Executive Branding
[#openIQUII - Workshop] Personal e Executive Branding[#openIQUII - Workshop] Personal e Executive Branding
[#openIQUII - Workshop] Personal e Executive Branding
 
ラルフローレン塗料とクーポンコードで
ラルフローレン塗料とクーポンコードでラルフローレン塗料とクーポンコードで
ラルフローレン塗料とクーポンコードで
 
Taz art01 f_sn_p_e
Taz art01 f_sn_p_eTaz art01 f_sn_p_e
Taz art01 f_sn_p_e
 
Environment quotes, green sayings, ecology, conservation, pollution, etc
Environment quotes, green sayings, ecology, conservation, pollution, etcEnvironment quotes, green sayings, ecology, conservation, pollution, etc
Environment quotes, green sayings, ecology, conservation, pollution, etc
 
Fundamental of computer
Fundamental of computerFundamental of computer
Fundamental of computer
 
Aa resume frank pullizzi new one 10 18-16
Aa resume frank pullizzi  new one  10 18-16Aa resume frank pullizzi  new one  10 18-16
Aa resume frank pullizzi new one 10 18-16
 
Blogging & e portfolios PD by Jocelyn Sutherland
Blogging & e portfolios PD by Jocelyn SutherlandBlogging & e portfolios PD by Jocelyn Sutherland
Blogging & e portfolios PD by Jocelyn Sutherland
 

Semelhante a Docker: ao vivo e a cores

Semelhante a Docker: ao vivo e a cores (20)

DeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to DockerDeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to Docker
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
AtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration trainingAtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration training
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
 
Check the version with fixes. Link in description
Check the version with fixes. Link in descriptionCheck the version with fixes. Link in description
Check the version with fixes. Link in description
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 
Docker
DockerDocker
Docker
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
Creating docker custom image
Creating docker custom imageCreating docker custom image
Creating docker custom image
 
Creating docker custom image
Creating docker custom imageCreating docker custom image
Creating docker custom image
 
Docker practice
Docker practiceDocker practice
Docker practice
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
 
Présentation de Docker
Présentation de DockerPrésentation de Docker
Présentation de Docker
 
Lab docker
Lab dockerLab docker
Lab docker
 
Docker engine - Indroduc
Docker engine - IndroducDocker engine - Indroduc
Docker engine - Indroduc
 
Docker Demo @ IuK Seminar
Docker Demo @ IuK SeminarDocker Demo @ IuK Seminar
Docker Demo @ IuK Seminar
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 

Último

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 

Último (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 

Docker: ao vivo e a cores

  • 1. Docker ao vivo e a cores Pedro Arthur P. R. Duarte pedroarthur.jedi@gmail.com
  • 5. E por que só agora? https://en.wikipedia.org/wiki/Docker_(software) 5
  • 7. Principais engines de tempo de execução http://docker.com/ http://coreos.com/rkt/ 7
  • 8. Execução de Processos em Containers https://coreos.com/rkt/docs/latest/rkt-vs-other-projects.html 8
  • 10. Baixando e executando containers r2@d2 $ docker pull debian:jessie jessie: Pulling from library/debian 386a066cd84a: Pull complete Digest: sha256:c1ce85a0f7126a3b5cbf7c57676b01b37c755b9ff9e2f39ca88181c02b985724 Status: Downloaded newer image for debian:jessie r1@d2 $ docker run -it debian:jessie /bin/bash root@c0c4c014d3af:/# ping 4.2.2.2 PING 4.2.2.2 (4.2.2.2): 56 data bytes 64 bytes from 4.2.2.2: icmp_seq=0 ttl=53 time=109.191 ms --- 4.2.2.2 ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max/stddev = 109.191/109.191/109.191/0.000 ms root@c0c4c014d3af:/# exit 0 r1@d2 $ docker run -t debian:jessie ping -c 1 4.2.2.2 # mostly the same as the previous command 10
  • 11. Construindo um Container: aplicação Servidor de Echo #!/ usr/bin/env python from twisted.internet.protocol import Protocol , Factory from twisted.internet import reactor from twisted.python import log from sys import stdout class Echo(Protocol ): def dataReceived (self , data ): log.msg("Received", data) self.transport.write(data) log. startLogging (stdout) log.msg("Echo server is starting") reactor.listenTCP (8000 , Factory. forProtocol (Echo )) reactor.run () 11
  • 12. Construindo um Container: Dockerfile Arquivo de Descrição do Container FROM debian:jessie RUN apt -get update && apt -get install -y python -twisted && apt -get clean COPY echo_server .py /usr/local/bin EXPOSE 8000 CMD exec /usr/local/bin/ echo_server .py 12
  • 13. Construindo um Container: build r2@d2 $ docker build -t poticon_echo_server:1.0 . Sending build context to Docker daemon 5.12 kB Step 1 : FROM debian:jessie ---> 73e72bf822ca Step 2 : RUN apt-get update && apt-get install -y python-twisted && apt ---> Running in e37b92a3c12b # a lot of apt-get-related output ---> 6fbd3015ca0c Removing intermediate container e37b92a3c12b Step 3 : COPY echo_server.py /usr/local/bin ---> 87add3168ac0 Removing intermediate container 956612405c96 Step 4 : EXPOSE 8000 ---> Running in 810fee23449d ---> 70890ad7e011 Removing intermediate container 810fee23449d Step 5 : CMD exec /usr/local/bin/echo_server.py ---> Running in 65fd3384e5eb ---> 1b46b966c54e Removing intermediate container 65fd3384e5eb Successfully built 1b46b966c54e
  • 14. Executando e Testando nosso container r2@d2 $ docker run -t --net=host poticon_echo_server:1.0 2016-11-24 12:53:19+0000 [-] Log opened. 2016-11-24 12:53:19+0000 [-] Echo server is starting 2016-11-24 12:53:19+0000 [-] Factory starting on 8000 2016-11-24 12:53:19+0000 [-] Starting factory <twisted.internet.protocol.Factory in 2016-11-24 12:53:28+0000 [Echo,0,127.0.0.1] Received Hi, there! # at another terminal; ts comes from moreutils r2@d2 $ nc 127.0.0.1 8000 | ts ’%F %T’ Hi, there! 2016-11-24 12:53:28 Hi, there! 14
  • 15. Composição de Serviços r2@d2 $ cat docker-compose.yaml version: ’2’ services: redis: image: redis postgresql: image: postgres environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=$PG_PASSWORD r2@d2 $ export PG_PASSWORD=p0t1c0n r2@d2 $ docker-compose up -d # -d puts them in background r2@d2 $ docker-compose logs # use -f to follow r2@d2 $ docker-compose down # mind other commands such as stop and start 15
  • 18. Links Úteis Tecnologias de Containers: – Docker: http://github.com/docker/ – Rkt: http://coreos.com/rkt Orquestradores de Containers – CoreOS: http://coreos.com – Kubernetes: http://github.com/kubernetes – Swarm: http://docker.com/swarm 18