SlideShare a Scribd company logo
INICIANDO COM DOCKER
Emmanuel Neri
@emmanuelnerii
www.emmanuelneri.com.br
EMMANUEL NERI
‣ Mestre em Desenvolvimento de Tecnologia
‣ Desenvolvedor (Java) desde 2010
‣ Tech lead na Jaya
DOCKER
CONTAINER
CONTAINERS VS VM
BENEFÍCIOS
▸ Portável
▸ Flexibilidade
▸ Escalável
▸ Lightweight
DOCKER
FUNCIONAMENTO
▸ Imagens
▸ Containers
SO
APP
COMANDOS
docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest:
sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
…
docker ps
CONTAINER ID|IMAGE|COMMAND|CREATED|STATUS|PORTS|NAMES
docker images
REPOSITORY|TAG|IMAGE ID|CREATED|SIZE
hello-world|latest|fce289e99eb9|7 months ago|1.84kB
DOCKER
▸ Docker registry
▸ Docker Host
▸ Imagens
▸ Containers
▸ Volumes
▸ Redes
▸ Daemon
▸ Docker Client
ARQUITETURA
DOCKERHUB
hub.docker.com
DOCKER RUN
docker run -it 
--name mongodb 
mongo:3.5
MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=64cbcf1206fe
db version v3.5.13
git version: 52bbaa007cd84631d6da811d9a05b59f2dfad4f3
OpenSSL version: OpenSSL 1.0.1t 3 May 2016
allocator: tcmalloc
modules: none
build environment:
distmod: debian81
distarch: x86_64
target_arch: x86_64
{ net: { bindIpAll: true } }
** See http://dochub.mongodb.org/core/prodnotes-filesystem
** NOTE: This is a development version (3.5.13) of MongoDB.
** Not recommended for production.
** WARNING: Access control is not enabled for the database.
** Read and write access to data and configuration is unrestricted.
Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
setting featureCompatibilityVersion to 3.6
waiting for connections on port 27017
DOCKER RUN
docker run -it 
--name file-db 
-e MONGO_INITDB_ROOT_USERNAME: root 
-e MONGO_INITDB_ROOT_PASSWORD: password 
mongo:3.5
DOCKERFILE
FROM openjdk:8-jdk-alpine
VOLUME /tmp
COPY target/devCia-*.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
Dockerfile
DOCKERFILE
docker build -t devcia/spring-boot .
Sending build context to Docker daemon 16.96MB
Step 1/4 : FROM openjdk:8-jdk-alpine
---> a3562aa0b991
Step 2/4 : VOLUME /tmp
---> Using cache
---> 681df48914d3
Step 3/4 : COPY target/devCia-*.jar app.jar
---> Using cache
---> dcdf13b91079
Step 4/4 : ENTRYPOINT ["java", "-jar", "/app.jar"]
---> Using cache
---> 98bc1828bab1
Successfully built 98bc1828bab1
Successfully tagged devcia/spring-boot:latest
DOCKERFILE
docker run devcia/spring-boot
. ____ _ __ _ _
/ / ___'_ __ _ _(_)_ __ __ _    
( ( )___ | '_ | '_| | '_ / _` |    
/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.7.RELEASE)


Tomcat initialized with port(s): 8080 (http)
Started DevCiaApplication in 2.593 seconds (JVM running for 3.121)
DOCKERFILE
docker run -p 8080:8080 devcia/spring-boot
. ____ _ __ _ _
/ / ___'_ __ _ _(_)_ __ __ _    
( ( )___ | '_ | '_| | '_ / _` |    
/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.7.RELEASE)


Tomcat initialized with port(s): 8080 (http)
Started DevCiaApplication in 2.593 seconds (JVM running for 3.121)
DOCKERFILE
▸ FROM
▸ MAINTAINER
▸ RUN
▸ CMD
▸ LABEL
▸ EXPOSE
▸ ENV
▸ ADD
▸ COPY
▸ ENTRYPOINT
▸ VOLUME
▸ USER
▸ WORKDIR
▸ ONBUILD
LINKS
docker run -it 
--name docker-postgres 
-e POSTGRES_DB=db 
-e POSTGRES_USER=postgres 
-e POSTGRES_PASSWORD=postgres 
postgres:10.4
docker run -it
--link docker-postgres 
-p 8080:8080 
emmanuelneri/spring-boot-docker-app
COMPOSE
version: '3'
services:
docker-app:
image: emmanuelneri/spring-boot-docker-app
ports:
- "8080:8080"
depends_on:
- docker-postgres
docker-postgres:
image: postgres:10.4
environment:
- POSTGRES_DB=db
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
docker-compose up
docker-compose stop
BACK-FRONT
version: '3'
services:
web:
image: despesas/despesas-web
ports:
- "3000:3000"
links:
- app
app:
image: despesas/despesas-app
ports:
- "8081:8081"
links:
- db
db:
image: postgres:9.6
ports:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=gestao-despesas
OUTROS CASES
▸ Ambientes de dev
▸ Testes automatizados
▸ Integração Continua
▸ Deploy Continuo
▸ Script automatizados
▸ Escalabilidade em produção
▸ Multi cloud
COMANDOS IMPORTANTES
‣ docker exec
‣ docker inspect
‣ docker logs
‣ docker stop
‣ docker rm -f
BOAS PRÁTICAS
‣ Usar tags das imagens
‣ Não deixar configurações fixas nas imagens
‣ Não armazenar estado
CONCLUSÃO
‣ Simples
‣ Utilizado de dev a produção
‣ Proporciona automatização
‣ Portável
‣ Escalável
emmanuelnerisouza@gmail.com
@emmanuelnerii
www.emmanuelneri.com.br
github.com/emmanuelneri
emmanuelnerisouza
DÚVIDAS?
Emmanuel Neri

More Related Content

PDF
When Docker ends, Chef begins ~ #idi2015 Incontro DevOps Italia
PDF
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
PDF
Docker e postgresql
PDF
Puppet and Vagrant in development
PDF
Capistrano deploy Magento project in an efficient way
PDF
From zero to Docker
PDF
Continuous Delivery di una WebApp - by example
PDF
Podman rootless containers
When Docker ends, Chef begins ~ #idi2015 Incontro DevOps Italia
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
Docker e postgresql
Puppet and Vagrant in development
Capistrano deploy Magento project in an efficient way
From zero to Docker
Continuous Delivery di una WebApp - by example
Podman rootless containers

What's hot (20)

PDF
Docker at Flux7
PDF
Docker 활용법: dumpdocker
PDF
Magento 2 Capistrano Deploy
PDF
Docker / Ansible
PDF
Docker deploy
PPTX
Running .NET on Docker
PDF
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
PPTX
Docker workshop
PDF
Vagrant + Docker provider [+Puppet]
PDF
Vagrant for real (codemotion rome 2016)
PDF
Ninja Build: Simple Guide for Beginners
PDF
Использование Docker в CI / Александр Акбашев (HERE Technologies)
PDF
Présentation "Docker + Kubernetes" @ Pastis.tech #2
PDF
Meetup C++ Floripa - Conan.io
PDF
PDF
Docker Compose to Production with Docker Swarm
PPTX
Start tracking your ruby infrastructure
PDF
Preparation study of_docker - (MOSG)
PPTX
Running Docker in Development & Production (DevSum 2015)
PDF
Docker, c'est bonheur !
Docker at Flux7
Docker 활용법: dumpdocker
Magento 2 Capistrano Deploy
Docker / Ansible
Docker deploy
Running .NET on Docker
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
Docker workshop
Vagrant + Docker provider [+Puppet]
Vagrant for real (codemotion rome 2016)
Ninja Build: Simple Guide for Beginners
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Présentation "Docker + Kubernetes" @ Pastis.tech #2
Meetup C++ Floripa - Conan.io
Docker Compose to Production with Docker Swarm
Start tracking your ruby infrastructure
Preparation study of_docker - (MOSG)
Running Docker in Development & Production (DevSum 2015)
Docker, c'est bonheur !
Ad

Similar to Iniciando com Docker (20)

PDF
Docker in Action
PDF
Docker Introduction.pdf
PPTX
Academy PRO: Docker. Part 4
PDF
Learning Docker with Thomas
PDF
Web Applications with Eclipse RT and Docker in the Cloud
PDF
AWS와 Docker Swarm을 이용한 쉽고 빠른 컨테이너 오케스트레이션 - AWS Summit Seoul 2017
PDF
Perspectives on Docker
PDF
Docker by Example - Basics
PPTX
Baking docker using chef
PPTX
Baking Docker Using Chef - ChefConf 2015
PDF
Improve your Java Environment with Docker
PPTX
Java microservicesdockerdockerhubusecase2
PPTX
When Docker Engine 1.12 features unleashes software architecture
PDF
How to create your own hack environment
PDF
Introduction to Kalabox
PDF
Docker dev, test & production (afas)
PDF
Docker for Java Developers
PDF
How to Dockerize Web Application using Docker Compose
PDF
Things I've learned working with Docker Support
Docker in Action
Docker Introduction.pdf
Academy PRO: Docker. Part 4
Learning Docker with Thomas
Web Applications with Eclipse RT and Docker in the Cloud
AWS와 Docker Swarm을 이용한 쉽고 빠른 컨테이너 오케스트레이션 - AWS Summit Seoul 2017
Perspectives on Docker
Docker by Example - Basics
Baking docker using chef
Baking Docker Using Chef - ChefConf 2015
Improve your Java Environment with Docker
Java microservicesdockerdockerhubusecase2
When Docker Engine 1.12 features unleashes software architecture
How to create your own hack environment
Introduction to Kalabox
Docker dev, test & production (afas)
Docker for Java Developers
How to Dockerize Web Application using Docker Compose
Things I've learned working with Docker Support
Ad

More from Emmanuel Neri (20)

PDF
Arquitetura orientada a eventos
PDF
Arquitetura reativa, a solução para os microserviços?
PDF
Preparando nossas aplicações para falharem com feature toggle e configurações...
PDF
Preparando nossa aplicação para falhar com feature toggle e configurações dis...
PDF
Combatendo code smells em Java
PDF
Configurações distribuídas com Spring Cloud Config
PDF
Lidando com desafios dos microserviços com a stack Spring Cloud Netflix
PDF
Trabalho Remoto
PDF
O Impacto da arquitetura de Micro Serviços nas soluções de software
PDF
A Cultura do Home Office
PDF
Combatendo code smells em aplicações Java
PDF
Construindo APIs de forma produtiva com Spring Boot, Spring Data e Spring MVC
PPTX
A trilogia Spring MVC + Spring Data + AngularJS
PPTX
Criando uma arquitetura escalável para processamento de arquivos com micro s...
PDF
Microservices: Mais que uma arquitetura de software, uma filosofia de desenvo...
PPTX
O comparativo de arquiteturas de software monolíticas em relação a arquitetur...
PPTX
Aplicação da arquitetura de micro serviços em softwares corporativos
PDF
Desenvolvimento baseado em componentes com JSF
PDF
Jett: Exporte Excel do jeito que seu cliente sempre sonhou
PDF
Análise e Design - RUP
Arquitetura orientada a eventos
Arquitetura reativa, a solução para os microserviços?
Preparando nossas aplicações para falharem com feature toggle e configurações...
Preparando nossa aplicação para falhar com feature toggle e configurações dis...
Combatendo code smells em Java
Configurações distribuídas com Spring Cloud Config
Lidando com desafios dos microserviços com a stack Spring Cloud Netflix
Trabalho Remoto
O Impacto da arquitetura de Micro Serviços nas soluções de software
A Cultura do Home Office
Combatendo code smells em aplicações Java
Construindo APIs de forma produtiva com Spring Boot, Spring Data e Spring MVC
A trilogia Spring MVC + Spring Data + AngularJS
Criando uma arquitetura escalável para processamento de arquivos com micro s...
Microservices: Mais que uma arquitetura de software, uma filosofia de desenvo...
O comparativo de arquiteturas de software monolíticas em relação a arquitetur...
Aplicação da arquitetura de micro serviços em softwares corporativos
Desenvolvimento baseado em componentes com JSF
Jett: Exporte Excel do jeito que seu cliente sempre sonhou
Análise e Design - RUP

Recently uploaded (20)

PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
System and Network Administration Chapter 2
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Introduction to Artificial Intelligence
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
How to Choose the Right IT Partner for Your Business in Malaysia
Wondershare Filmora 15 Crack With Activation Key [2025
Softaken Excel to vCard Converter Software.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Understanding Forklifts - TECH EHS Solution
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
VVF-Customer-Presentation2025-Ver1.9.pptx
CHAPTER 2 - PM Management and IT Context
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
System and Network Administration Chapter 2
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Odoo POS Development Services by CandidRoot Solutions
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Operating system designcfffgfgggggggvggggggggg
Introduction to Artificial Intelligence

Iniciando com Docker

  • 1. INICIANDO COM DOCKER Emmanuel Neri @emmanuelnerii www.emmanuelneri.com.br
  • 2. EMMANUEL NERI ‣ Mestre em Desenvolvimento de Tecnologia ‣ Desenvolvedor (Java) desde 2010 ‣ Tech lead na Jaya
  • 9. COMANDOS docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f Status: Downloaded newer image for hello-world:latest Hello from Docker! … docker ps CONTAINER ID|IMAGE|COMMAND|CREATED|STATUS|PORTS|NAMES docker images REPOSITORY|TAG|IMAGE ID|CREATED|SIZE hello-world|latest|fce289e99eb9|7 months ago|1.84kB
  • 10. DOCKER ▸ Docker registry ▸ Docker Host ▸ Imagens ▸ Containers ▸ Volumes ▸ Redes ▸ Daemon ▸ Docker Client
  • 13. DOCKER RUN docker run -it --name mongodb mongo:3.5 MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=64cbcf1206fe db version v3.5.13 git version: 52bbaa007cd84631d6da811d9a05b59f2dfad4f3 OpenSSL version: OpenSSL 1.0.1t 3 May 2016 allocator: tcmalloc modules: none build environment: distmod: debian81 distarch: x86_64 target_arch: x86_64 { net: { bindIpAll: true } } ** See http://dochub.mongodb.org/core/prodnotes-filesystem ** NOTE: This is a development version (3.5.13) of MongoDB. ** Not recommended for production. ** WARNING: Access control is not enabled for the database. ** Read and write access to data and configuration is unrestricted. Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data' setting featureCompatibilityVersion to 3.6 waiting for connections on port 27017
  • 14. DOCKER RUN docker run -it --name file-db -e MONGO_INITDB_ROOT_USERNAME: root -e MONGO_INITDB_ROOT_PASSWORD: password mongo:3.5
  • 15. DOCKERFILE FROM openjdk:8-jdk-alpine VOLUME /tmp COPY target/devCia-*.jar app.jar ENTRYPOINT ["java", "-jar", "/app.jar"] Dockerfile
  • 16. DOCKERFILE docker build -t devcia/spring-boot . Sending build context to Docker daemon 16.96MB Step 1/4 : FROM openjdk:8-jdk-alpine ---> a3562aa0b991 Step 2/4 : VOLUME /tmp ---> Using cache ---> 681df48914d3 Step 3/4 : COPY target/devCia-*.jar app.jar ---> Using cache ---> dcdf13b91079 Step 4/4 : ENTRYPOINT ["java", "-jar", "/app.jar"] ---> Using cache ---> 98bc1828bab1 Successfully built 98bc1828bab1 Successfully tagged devcia/spring-boot:latest
  • 17. DOCKERFILE docker run devcia/spring-boot . ____ _ __ _ _ / / ___'_ __ _ _(_)_ __ __ _ ( ( )___ | '_ | '_| | '_ / _` | / ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |___, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.7.RELEASE) 
 Tomcat initialized with port(s): 8080 (http) Started DevCiaApplication in 2.593 seconds (JVM running for 3.121)
  • 18. DOCKERFILE docker run -p 8080:8080 devcia/spring-boot . ____ _ __ _ _ / / ___'_ __ _ _(_)_ __ __ _ ( ( )___ | '_ | '_| | '_ / _` | / ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |___, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.7.RELEASE) 
 Tomcat initialized with port(s): 8080 (http) Started DevCiaApplication in 2.593 seconds (JVM running for 3.121)
  • 19. DOCKERFILE ▸ FROM ▸ MAINTAINER ▸ RUN ▸ CMD ▸ LABEL ▸ EXPOSE ▸ ENV ▸ ADD ▸ COPY ▸ ENTRYPOINT ▸ VOLUME ▸ USER ▸ WORKDIR ▸ ONBUILD
  • 20. LINKS docker run -it --name docker-postgres -e POSTGRES_DB=db -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres:10.4 docker run -it --link docker-postgres -p 8080:8080 emmanuelneri/spring-boot-docker-app
  • 21. COMPOSE version: '3' services: docker-app: image: emmanuelneri/spring-boot-docker-app ports: - "8080:8080" depends_on: - docker-postgres docker-postgres: image: postgres:10.4 environment: - POSTGRES_DB=db - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres docker-compose up docker-compose stop
  • 22. BACK-FRONT version: '3' services: web: image: despesas/despesas-web ports: - "3000:3000" links: - app app: image: despesas/despesas-app ports: - "8081:8081" links: - db db: image: postgres:9.6 ports: - "5432:5432" environment: - POSTGRES_PASSWORD=postgres - POSTGRES_USER=postgres - POSTGRES_DB=gestao-despesas
  • 23. OUTROS CASES ▸ Ambientes de dev ▸ Testes automatizados ▸ Integração Continua ▸ Deploy Continuo ▸ Script automatizados ▸ Escalabilidade em produção ▸ Multi cloud
  • 24. COMANDOS IMPORTANTES ‣ docker exec ‣ docker inspect ‣ docker logs ‣ docker stop ‣ docker rm -f
  • 25. BOAS PRÁTICAS ‣ Usar tags das imagens ‣ Não deixar configurações fixas nas imagens ‣ Não armazenar estado
  • 26. CONCLUSÃO ‣ Simples ‣ Utilizado de dev a produção ‣ Proporciona automatização ‣ Portável ‣ Escalável