SlideShare a Scribd company logo
1 of 35
Download to read offline
DOCKER
[ Docker ]
Todo lo que quiso saber sobre Docker y seguramente ya tuvo oportunidad de escuchar
César Capillas <cesar at zylk.net>
DOCKER
This talk contains:
● Intro
● Docker engine and definitions
● How to use Docker Images
● How to create Docker Images
● Hands on Docker
● Advanced concepts: docker-compose, portainer
DOCKER
A container (what is this ?)
● It is an operating system process, that provides:
● A standarized packaging for software and dependencies
● Isolation of apps from each other
● It is not a virtual machine, but it is often compared.
● It provides isolation in terms of:
● Network, Process, User…
● One important feature is that data is ephemeral by default
DOCKER
A container (what is this ?)
https://www.altexsoft.com/blog/docker-pros-and-cons/
DOCKER
Benefits
● Lightweight / Speed
● No OS to boot applications online in seconds
→
● Highly Portable
● Ability to move between infrastructure
● Easily and quickly provisionable
● Real time provisioning
● Efficiency:
● Less OS overhead
● Native system performance
DOCKER
Docker Intro
DOCKER
The Docker engine
● It’s a client-server app for running containers
● A server engine (process) with a daemon process called
dockerd
– It provides a REST API for talking with docker
● A command line interface docker (CLI):
– It runs containers
– It is able to manage network and volumes (storage)
DOCKER
The Docker engine
Learning Docker – Packt Publishing
DOCKER
The Docker family
● Two versions:
● Docker Community Edition
– Free, community-supported product for delivering a
container solution
● Docker Enterprise Edition
– Subscription based, commercially supported for
delivering a secure software supply chain
DOCKER
The Docker basics
● Image: Read-only template with instructions for creating a
Docker container.
● Container: Runnable instance of an image.
● Data Volume: Storage folder inside or outside of an image.
● Network: Network interface to connect the container to
default network.
DOCKER
Docker architecture
DOCKER
Sharing images
● Docker Registry
● You obtain Docker Images from a public (or private)
registry (repository of images)
● When building an image, it is only available in local
● Then you may need to push to a registry
– Docker Hub
– Nexus 3
● Once shared, other people can pull the image
DOCKER
Creating images
● Using “Dockerfile”
● FROM Desde qué imagen parto
→
● ENV Definir variables de entorno
→
● ADD Añadir un archivo local en la imagen
→
● COPY
● RUN
● CMD
DOCKER
[ Hands on ]
$ mkdir work
$ cd work
$ git clone https://zgit.zylk.net/alfresco/imasd/dx-dockerlab.git
$ cd dx-dockerlab
DOCKER
Hands on
0)Prerrequisites (install docker environment)
1)Package and build a custom app with Docker
2)Remembering Tomcat (Revenge)
3)Use commercial databases with Docker (SQL Server)
4)Using docker-compose
5)Docker resources for Apache SOLR
6)Docker resources for Liferay
7)Docker resources for Alfresco
DOCKER
Example 1: Deploying a war in Tomcat
FROM tomcat:8.0-alpine
ADD apps/jolokia.war /usr/local/tomcat/webapps/
EXPOSE 8080
CMD ["catalina.sh", "run"]
# Compilo la custom image con el fichero Dockerfile
$ docker build -t myjolokia .
# Creo el contenedor y lo ejecuto en foreground
$ docker run -p 8888:8080 myjolokia
DOCKER
Common commands in Docker
$ docker -v
Docker version 19.03.6, build 369ce74a3c
# Para ver tus imágenes locales
$ docker images
# Para ver los containers-id’s que se estan ejecutando
$ docker ps
$ docker ps -a
# Para ejecutar una imagen de docker en background
$ docker run -d <docker-image>
# Para ver los logs de un container
$ docker logs -f <container-id>
# Para inspeccionar el container que estás ejecutando
$ docker exec -it <container-id> /bin/bash
# Para buscar imágenes en Docker Hub
$ docker search tomcat
# Para descargar una imagen
$ docker pull mcr.microsoft.com/mssql/server:2017-latest
DOCKER
Example 2: Remembering Tomcat
● Change server.xml configuration file in Tomcat to work in
8998 port instead of default 8080.
● Change in Dockerfile the corresponding port nating.
● 8888 8998
→
● Customize JVM options in setenv.sh to set Memory Heap
● -Xmx1024m
● Check Tomcat logs
● How to set Docker machine in background ?
DOCKER
Example 2: Remembering Tomcat
FROM tomcat:8.0-alpine
ADD config/server.xml /usr/local/tomcat/conf/server.xml
ADD config/setenv.sh /usr/local/tomcat/bin/
ADD apps/jolokia.war /usr/local/tomcat/webapps/
EXPOSE 8998
CMD ["catalina.sh", "run"]
# Compilo la custom image con el fichero Dockerfile
$ docker build -t myjolokia2 .
# Ejecuto el docker en background
$ docker run -d -p 8888:8998 --name=mytomcat8 myjolokia2
DOCKER
Example 3: Using commercial databases
$ docker pull mcr.microsoft.com/mssql/server:2017-latest
$ docker run -d -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=7y1K7y1K!" -p
1433:1433 --name sqlserver2017 --hostname sqlserver2017 -d
mcr.microsoft.com/mssql/server:2017-latest
# First we can try to check if the default port is available:
$ nc -v localhost 1433
Connection to localhost 1433 port [tcp/ms-sql-s] succeeded!
DOCKER
An example: Using MS-SQLServer
# In the following, we are going to create a database for Alfresco. A
possibility is to run sqlcmd utility inside docker machine:
$ docker exec -it sqlserver2017 "bash"
root@de2f9e36fd46:/# /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P
'7y1K7y1K!'
1> CREATE DATABASE alfresco6
2> SELECT Name from sys.Databases
3> GO
master
tempdb
model
msdb
alfresco6
1> ALTER DATABASE alfresco6 SET ALLOW_SNAPSHOT_ISOLATION ON;
2> GO
1> QUIT
DOCKER
[ More advanced concepts ]
DOCKER
Composing images with Docker Compose
● Docker Compose
● Provides the composition of a defined setup with
several Docker images.
● It uses a YAML file (docker-compose.yml)
● It defines, networks, ports, services, enviroment
variables…
● $ docker-compose up
DOCKER
Example 4:
●
Define local volume to preserve tomcat logs in local.
● Set mem_limit for this service
● Set JVM variables and db.driver in JAVA_OPTS
●
Add extra_hosts for connecting to external mysql (sqldev host)
DOCKER
Example 4:
●
What is the problem in this compose ?
version: '3.1'
services:
tomcat:
image: tomcat:8.0-alpine
ports:
- 8888:8080
volumes:
- ./logs:/usr/local/tomcat/logs
mem_limit: 1500m
environment:
JAVA_OPTS: "
-Ddb.driver=org.gjt.mm.mysql.Driver
-Xms512m -Xmx1024m
"
extra_hosts:
- "sqldev.zylk.net:192.168.1.100"
DOCKER
SOLR Docker Resources
● https://solr.apache.org/guide/solr/latest/deployment-guide/solr-in-
docker.html
DOCKER
Liferay Docker Resources
● Leveraging Docker:
● https://help.liferay.com/hc/en-us/articles/360022307392-
Leveraging-Docker
● https://hub.docker.com/r/liferay/portal
DOCKER
Alfresco Docker Resources
● ACS Community Deployment
● https://github.com/Alfresco/acs-community-deployment
● Docker Installer
● https://github.com/Alfresco/alfresco-docker-installer
DOCKER
Using Portainer for docker management
● Making Docker Management Easy
● https://www.portainer.io/
DOCKER
Managing Images
● A Docker Swarm node to manage remotely Docker
containers.
● Provides a graphical interface for creating and executing
docker images via Docker Compose.
● It is able to use a local registry (Nexus) for custom Docker
images.
DOCKER
Common commands for Docker Swarm
$ docker -v
Docker version 19.03.6, build 369ce74a3c
$ export DOCKER_HOST=tcp://dockyard.zylk.net:2376
#$ unset $DOCKER_HOST
$ docker stack ls
$ docker stack deploy -c docker-compose.yml icingalf
$ docker stack rm icingalf
$ docker ps
$ docker ps --filter="name=cas"
$ docker ps --format="{{.Names}}" | sort
$ docker exec -it <container-id> /bin/bash
$ docker logs -f <TAB>
DOCKER
Devops Lifecycle with Docker
DOCKER
Zylk for reading (Blog Post)
● Using MS-SQLServer with a docker container for developing (outdated)
●
https://www.zylk.net/es/web-2-0/blog/-/blogs/using-docker-image
s-for-enterprise-databases-with-alfresco
● Managing docker images for generating production infrastructure
● https://www.zylk.net/es/web-2-0/blog/-/blogs/managing-docker-i
mages-for-generating-production-infrastructure
● Testing new features on products with Dockerfiles
● https://www.zylk.net/es/web-2-0/blog/-/blogs/testing-new-feature
s-in-elastic-search-7-with-docker
●
Analyzing logs with Elastic and Docker.
● https://www.zylk.net/es/web-2-0/blog/-/blogs/analyzing-tomcat-lo
g-access-data-with-docker-elk-resources
DOCKER
External Links
● https://docs.docker.com
● https://hub.docker.com
● https://github.com/docker/community
DOCKER
[ Thanks ]

More Related Content

Similar to DockerCC.pdf

Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tipsSamuel Chow
 
Docker HK Meetup - 201707
Docker HK Meetup - 201707Docker HK Meetup - 201707
Docker HK Meetup - 201707Clarence Ho
 
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 ProductionBen Hall
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerEric Smalling
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Developmentmsyukor
 
Docker on Power Systems
Docker on Power SystemsDocker on Power Systems
Docker on Power SystemsCesar Maciel
 
Dockers & kubernetes detailed - Beginners to Geek
Dockers & kubernetes detailed - Beginners to GeekDockers & kubernetes detailed - Beginners to Geek
Dockers & kubernetes detailed - Beginners to GeekwiTTyMinds1
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruSwaminathan Vetri
 
Docker in a JS Developer’s Life
Docker in a JS Developer’s LifeDocker in a JS Developer’s Life
Docker in a JS Developer’s LifeGlobalLogic Ukraine
 

Similar to DockerCC.pdf (20)

DOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDESDOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDES
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
Docker HK Meetup - 201707
Docker HK Meetup - 201707Docker HK Meetup - 201707
Docker HK Meetup - 201707
 
How to _docker
How to _dockerHow to _docker
How to _docker
 
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
 
Docker, but what it is?
Docker, but what it is?Docker, but what it is?
Docker, but what it is?
 
From zero to Docker
From zero to DockerFrom zero to Docker
From zero to Docker
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with Docker
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Development
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Docker on Power Systems
Docker on Power SystemsDocker on Power Systems
Docker on Power Systems
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
Docker
DockerDocker
Docker
 
Dockers & kubernetes detailed - Beginners to Geek
Dockers & kubernetes detailed - Beginners to GeekDockers & kubernetes detailed - Beginners to Geek
Dockers & kubernetes detailed - Beginners to Geek
 
Docker up and running
Docker up and runningDocker up and running
Docker up and running
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
 
Docker in a JS Developer’s Life
Docker in a JS Developer’s LifeDocker in a JS Developer’s Life
Docker in a JS Developer’s Life
 

Recently uploaded

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Recently uploaded (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

DockerCC.pdf

  • 1. DOCKER [ Docker ] Todo lo que quiso saber sobre Docker y seguramente ya tuvo oportunidad de escuchar César Capillas <cesar at zylk.net>
  • 2. DOCKER This talk contains: ● Intro ● Docker engine and definitions ● How to use Docker Images ● How to create Docker Images ● Hands on Docker ● Advanced concepts: docker-compose, portainer
  • 3. DOCKER A container (what is this ?) ● It is an operating system process, that provides: ● A standarized packaging for software and dependencies ● Isolation of apps from each other ● It is not a virtual machine, but it is often compared. ● It provides isolation in terms of: ● Network, Process, User… ● One important feature is that data is ephemeral by default
  • 4. DOCKER A container (what is this ?) https://www.altexsoft.com/blog/docker-pros-and-cons/
  • 5. DOCKER Benefits ● Lightweight / Speed ● No OS to boot applications online in seconds → ● Highly Portable ● Ability to move between infrastructure ● Easily and quickly provisionable ● Real time provisioning ● Efficiency: ● Less OS overhead ● Native system performance
  • 7. DOCKER The Docker engine ● It’s a client-server app for running containers ● A server engine (process) with a daemon process called dockerd – It provides a REST API for talking with docker ● A command line interface docker (CLI): – It runs containers – It is able to manage network and volumes (storage)
  • 8. DOCKER The Docker engine Learning Docker – Packt Publishing
  • 9. DOCKER The Docker family ● Two versions: ● Docker Community Edition – Free, community-supported product for delivering a container solution ● Docker Enterprise Edition – Subscription based, commercially supported for delivering a secure software supply chain
  • 10. DOCKER The Docker basics ● Image: Read-only template with instructions for creating a Docker container. ● Container: Runnable instance of an image. ● Data Volume: Storage folder inside or outside of an image. ● Network: Network interface to connect the container to default network.
  • 12. DOCKER Sharing images ● Docker Registry ● You obtain Docker Images from a public (or private) registry (repository of images) ● When building an image, it is only available in local ● Then you may need to push to a registry – Docker Hub – Nexus 3 ● Once shared, other people can pull the image
  • 13. DOCKER Creating images ● Using “Dockerfile” ● FROM Desde qué imagen parto → ● ENV Definir variables de entorno → ● ADD Añadir un archivo local en la imagen → ● COPY ● RUN ● CMD
  • 14. DOCKER [ Hands on ] $ mkdir work $ cd work $ git clone https://zgit.zylk.net/alfresco/imasd/dx-dockerlab.git $ cd dx-dockerlab
  • 15. DOCKER Hands on 0)Prerrequisites (install docker environment) 1)Package and build a custom app with Docker 2)Remembering Tomcat (Revenge) 3)Use commercial databases with Docker (SQL Server) 4)Using docker-compose 5)Docker resources for Apache SOLR 6)Docker resources for Liferay 7)Docker resources for Alfresco
  • 16. DOCKER Example 1: Deploying a war in Tomcat FROM tomcat:8.0-alpine ADD apps/jolokia.war /usr/local/tomcat/webapps/ EXPOSE 8080 CMD ["catalina.sh", "run"] # Compilo la custom image con el fichero Dockerfile $ docker build -t myjolokia . # Creo el contenedor y lo ejecuto en foreground $ docker run -p 8888:8080 myjolokia
  • 17. DOCKER Common commands in Docker $ docker -v Docker version 19.03.6, build 369ce74a3c # Para ver tus imágenes locales $ docker images # Para ver los containers-id’s que se estan ejecutando $ docker ps $ docker ps -a # Para ejecutar una imagen de docker en background $ docker run -d <docker-image> # Para ver los logs de un container $ docker logs -f <container-id> # Para inspeccionar el container que estás ejecutando $ docker exec -it <container-id> /bin/bash # Para buscar imágenes en Docker Hub $ docker search tomcat # Para descargar una imagen $ docker pull mcr.microsoft.com/mssql/server:2017-latest
  • 18. DOCKER Example 2: Remembering Tomcat ● Change server.xml configuration file in Tomcat to work in 8998 port instead of default 8080. ● Change in Dockerfile the corresponding port nating. ● 8888 8998 → ● Customize JVM options in setenv.sh to set Memory Heap ● -Xmx1024m ● Check Tomcat logs ● How to set Docker machine in background ?
  • 19. DOCKER Example 2: Remembering Tomcat FROM tomcat:8.0-alpine ADD config/server.xml /usr/local/tomcat/conf/server.xml ADD config/setenv.sh /usr/local/tomcat/bin/ ADD apps/jolokia.war /usr/local/tomcat/webapps/ EXPOSE 8998 CMD ["catalina.sh", "run"] # Compilo la custom image con el fichero Dockerfile $ docker build -t myjolokia2 . # Ejecuto el docker en background $ docker run -d -p 8888:8998 --name=mytomcat8 myjolokia2
  • 20. DOCKER Example 3: Using commercial databases $ docker pull mcr.microsoft.com/mssql/server:2017-latest $ docker run -d -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=7y1K7y1K!" -p 1433:1433 --name sqlserver2017 --hostname sqlserver2017 -d mcr.microsoft.com/mssql/server:2017-latest # First we can try to check if the default port is available: $ nc -v localhost 1433 Connection to localhost 1433 port [tcp/ms-sql-s] succeeded!
  • 21. DOCKER An example: Using MS-SQLServer # In the following, we are going to create a database for Alfresco. A possibility is to run sqlcmd utility inside docker machine: $ docker exec -it sqlserver2017 "bash" root@de2f9e36fd46:/# /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '7y1K7y1K!' 1> CREATE DATABASE alfresco6 2> SELECT Name from sys.Databases 3> GO master tempdb model msdb alfresco6 1> ALTER DATABASE alfresco6 SET ALLOW_SNAPSHOT_ISOLATION ON; 2> GO 1> QUIT
  • 23. DOCKER Composing images with Docker Compose ● Docker Compose ● Provides the composition of a defined setup with several Docker images. ● It uses a YAML file (docker-compose.yml) ● It defines, networks, ports, services, enviroment variables… ● $ docker-compose up
  • 24. DOCKER Example 4: ● Define local volume to preserve tomcat logs in local. ● Set mem_limit for this service ● Set JVM variables and db.driver in JAVA_OPTS ● Add extra_hosts for connecting to external mysql (sqldev host)
  • 25. DOCKER Example 4: ● What is the problem in this compose ? version: '3.1' services: tomcat: image: tomcat:8.0-alpine ports: - 8888:8080 volumes: - ./logs:/usr/local/tomcat/logs mem_limit: 1500m environment: JAVA_OPTS: " -Ddb.driver=org.gjt.mm.mysql.Driver -Xms512m -Xmx1024m " extra_hosts: - "sqldev.zylk.net:192.168.1.100"
  • 26. DOCKER SOLR Docker Resources ● https://solr.apache.org/guide/solr/latest/deployment-guide/solr-in- docker.html
  • 27. DOCKER Liferay Docker Resources ● Leveraging Docker: ● https://help.liferay.com/hc/en-us/articles/360022307392- Leveraging-Docker ● https://hub.docker.com/r/liferay/portal
  • 28. DOCKER Alfresco Docker Resources ● ACS Community Deployment ● https://github.com/Alfresco/acs-community-deployment ● Docker Installer ● https://github.com/Alfresco/alfresco-docker-installer
  • 29. DOCKER Using Portainer for docker management ● Making Docker Management Easy ● https://www.portainer.io/
  • 30. DOCKER Managing Images ● A Docker Swarm node to manage remotely Docker containers. ● Provides a graphical interface for creating and executing docker images via Docker Compose. ● It is able to use a local registry (Nexus) for custom Docker images.
  • 31. DOCKER Common commands for Docker Swarm $ docker -v Docker version 19.03.6, build 369ce74a3c $ export DOCKER_HOST=tcp://dockyard.zylk.net:2376 #$ unset $DOCKER_HOST $ docker stack ls $ docker stack deploy -c docker-compose.yml icingalf $ docker stack rm icingalf $ docker ps $ docker ps --filter="name=cas" $ docker ps --format="{{.Names}}" | sort $ docker exec -it <container-id> /bin/bash $ docker logs -f <TAB>
  • 33. DOCKER Zylk for reading (Blog Post) ● Using MS-SQLServer with a docker container for developing (outdated) ● https://www.zylk.net/es/web-2-0/blog/-/blogs/using-docker-image s-for-enterprise-databases-with-alfresco ● Managing docker images for generating production infrastructure ● https://www.zylk.net/es/web-2-0/blog/-/blogs/managing-docker-i mages-for-generating-production-infrastructure ● Testing new features on products with Dockerfiles ● https://www.zylk.net/es/web-2-0/blog/-/blogs/testing-new-feature s-in-elastic-search-7-with-docker ● Analyzing logs with Elastic and Docker. ● https://www.zylk.net/es/web-2-0/blog/-/blogs/analyzing-tomcat-lo g-access-data-with-docker-elk-resources
  • 34. DOCKER External Links ● https://docs.docker.com ● https://hub.docker.com ● https://github.com/docker/community