SlideShare ist ein Scribd-Unternehmen logo
1 von 63
Downloaden Sie, um offline zu lesen
Jadson Santos
Containerizing a Web Application with Vue.js and
Java
Container
• Seaports before container were a mess
27/09/2021 Docker 2
Container
• After container, load a ship became faster
27/09/2021 Docker 3
Container
• How setup the execution environment
• 1o Install directly in SO: Very complex, several different configurations
• 2o Use virtual machines like VMWare, Virtual Box: memory and processing
consumption is too high
• 3o Use a container: it's possible to run an application with all the required
settings (environment variables, packages, etc.) with minimal impact
27/09/2021 Docker 4
Container
• Containers isolate microservice processes and applications into smaller
instances that utilize only the virtualized operating system rather than the
full virtual machine and the entire complement of abstracted hardware that
VM includes
• For containers, they operate more as fully isolated sandboxes, with only the
minimal kernel of the operating system present for each container.
27/09/2021 Docker 5
Container
27/09/2021 Docker 6
Installation
27/09/2021 Docker 7
Docker
• Docker is a set of platform-as-a-service products that use operating system-
level virtualization to deliver software in packages called containers.
• Docker do not create the container technology, but was the first tool to let is
popular and and relatively easy to use.
27/09/2021 Docker 8
Registry
Docker Daemon
Containers Images
Client
docker run
docker build
docker pull
Docker
• Client: Client receiving and executes the commands of users
• Docker Daemon: Who manages the containers
• Registry: Where the images are stored
27/09/2021 Docker 9
Installation
• Linux
• First, install some prerequisite packages that let apt use packages over HTTPS:
• sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-
properties-common
• Add the GPG key to the official Docker repository on your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
-
• Add the Docker repository to the APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu
focal stable"
27/09/2021 Docker 10
Installation
• Linux
• Then update the database with the Docker packages from the newly added repository:
• sudo apt update
• Now, install the Docker
• sudo apt install docker-ce
• Add your username to the docker group:
• sudo usermod -aG docker “user”
27/09/2021 Docker 11
Installation
• Mac OS
• Go to https://hub.docker.com/
• Download Docker Desktop for Mac
• Docker is native for Linux, to run on Windows and MacOS we need the Docker Desktop
27/09/2021 Docker 12
Installation
• Mac OS
• Type docker version
27/09/2021 Docker 13
Docker Introduction
• Hello World
docker container run hello-world
27/09/2021 Docker 14
image name
Docker Introduction
• Hello World
• There is an image “hello-world” locally?
27/09/2021 Docker 15
Registry
Docker Daemon
Containers Images
Client
docker run
Docker Introduction
• Hello World
• Download from registry (https://hub.docker.com/)
27/09/2021 Docker 16
Registry
Docker Daemon
Containers Images
Client
docker run
Docker Introduction
• Hello World
• Run the container that is an instance of “hello-world” image
27/09/2021 Docker 17
Registry
Docker Daemon
Containers Images
Client
docker run
Docker Introduction
• Docker hub
• Docker hub is the default docker registry
• It has unlimited public repositories
27/09/2021 Docker 18
Docker Introduction
• Docker hub
• You can search for images
• Give preference to official
images
27/09/2021 Docker 19
Docker Introduction
• Docker hub
• Each image has several tags
• Choose the image that best fits your application requirements
27/09/2021 Docker 20
Docker Introduction
• Docker hub
• You can install local registry to your company.
27/09/2021 Docker 21
Docker Introduction
• List the containers running
• docker container ls
• List all containers
• docker container ls -a
27/09/2021 Docker 22
Docker Introduction
• Give a name to the container
• docker container run -–name my_hello_container hello-world
27/09/2021 Docker 23
Docker Introduction
• Removing a container
• docker container rm <ID or NAME>
• Restarting the container
• docker container restart <ID or NAME>
• Stopping the container
• docker container stop <ID or NAME>
27/09/2021 Docker 24
Docker Introduction
• Accessing the container
• Download the “ubuntu” image, run the container using this image and give me access the
/bin/bash application inside de container
• docker container run -it ubuntu /bin/bash
• Accessing the container when it is running
• docker container exec -it ubuntu /bin/bash
27/09/2021 Docker 25
In this case, the application argument
stay after image name, in the other
cases, image name is always the last
argument of command
Docker Port Binding
• To have access an application running inside the container, it is necessary to
define a port from the port bind. In the format HOST : CONTAINER
• docker container run -p 27017:27017 mongo
27/09/2021 Docker 26
Bing the mongo DB 27017 port (mongo db goes up
inside de container) to the 27017 HOST port
HOST : Mongo DB
Docker Images
• Docker images act as a template to build a Docker container.
• Docker images contains layers that install libraries, tools, dependences, files needed to
make your application run.
• Docker images layers increase reusability, decrease disk usage, and speed up docker
build by allowing each step to be cached.
• We need to create an image containing our application to run it on a Docker
27/09/2021 Docker 27
Image
Layer 01
Layer 02
Layer 03
Layer 04
Layer N
Docker Images
• The easiest way to create an image is via the Dockerfile file
• Example of Dockerfile of a simple Node application
27/09/2021 Docker 28
Docker Images
• The easiest way to create an image is via the Dockerfile file
• Example of Dockerfile of a simple Node application
27/09/2021 Docker 29
Docker Images
• The easiest way to create an image is via the Dockerfile file
• Starting downloading a node image
• Create a working directory (WORKDIR == “mkdir /app” and “cd /app”)
• Copies the .package.json and .package-lock.json file
• Run “npm install” to download and install node dependencies
• Copy the other files of project
• When the container goes up, execute the command “node app.js"
27/09/2021 Docker 30
Docker Images
• Build a image with your node application
• docker build . -t jadsonjs/appnode:v1
27/09/2021 Docker 31
Image name
(name space + repository + tag)
Docker Images
• List the images
docker image ls
27/09/2021 Docker 32
Docker Images
• Execute your node application inside the docker
docker container run –d –p 8080:8081 -–name my_appnode_container jadsonjs/appnode:v1
docker container ls
27/09/2021 Docker 33
Image name
Container name
Run in background
Bind the 8081 NODE application port to 8080 HOST port
Docker Images
• Execute your node application inside the docker
27/09/2021 Docker 34
Docker Images
• Publish image to docker hub
• Publish the image to my account do docker hub as a public image that other people can
use.
docker login
docker push jadsonjs/appnode:v1
27/09/2021 Docker 35
Docker Images
• Publish image to docker hub
• Publish the image to my account do docker hub as a public image that other people can
use.
27/09/2021 Docker 36
Docker Networks
• If you are going to run 2 or more applications in 2 or more separate containers
and need them to communicate. Must create a network between these
containers
docker network create my-app-net
docker container run -–name api –d -p 8080:8080 -–network=my-app-net
jadsonjs/appnode:v1
docker container run -–name mongodb -d -p 27017:27017 -e USER=user -e
PASS=1234 -–network=my-app-net mongo:5.0.3
27/09/2021 Docker 37
Docker Volumes
• Used to save data if you kill and upload the container again. Example:
Container of a database.
• Link container file system with the host file system
• This can be done via directory bind. In the format HOST : CONTAINER, similar with port
bind
docker container run -–name bancoDeDadosMongo -d -p 27017:27017 -e
USER=user -e PASS=1234 -–network=api-net -v “/usr/local/mongodb:/data/db”
mongo:5.0.3
27/09/2021 Docker 38
Bind the /data/db mongo db directory with /usr/local/mongodb HOST directory
In other words, the data will be save in /usr/local/mongodb HOST directory
Docker Volumes
• Creating a volume
docker volume create mongodb_vol
docker container run -–name mongodb -d -p 27017:27017 -e USER=user -e
PASS=1234 -–network=my-app-net -v “mongodb_vol:/data/db” mongo:5.0.3
27/09/2021 Docker 39
Bind the /data/db mongo db directory with a mongodb_vol create by the container
mongodb_vol is a directory in HOST machine created and managed by container
Docker Volumes
• Creating a volume
docker volume ls
docker volume inspect mongo_db_vol
27/09/2021 Docker 40
Vue JS Application on Docker
27/09/2021 Docker 41
Vue JS Application on Docker
• Let’s create a simple VUE calculator
application with de command
• vue create calculator-front-end
• The application will be a simple calculator that
will call a back-end application written in Java.
• The front end application will be deployed
using nginx server.
• The back end application will be deployed in
another Docker container.
27/09/2021 Docker 42
Vue JS Application on Docker
• Let’s create a simple VUE calculator application
• We create a nginx.conf file in the project root that configure your “calculator” application
• When somebody type “/calculator” on url, the nginx serve should execute the /calculator/index.html of a
VUE Single Page Application project
• This file will be copy into the container file system.
27/09/2021 Docker 43
Vue JS Application on Docker
• Let’s create a simple VUE calculator application
• For the vue app work inside nginx server, we have to define a context to VUE application when
execute on Docker, we make this in the vue.config.js file.
27/09/2021 Docker 44
Vue JS Application on Docker
• In the dockerfile file, we define some
steps to build our image
• Build Steps:
• Download a “node” image
• Create a temp directory “app” and copy
package*.json files to it
• Install all Vue dependences
• Copy the other files and make the build of
project
• Execution Steps:
• Now, download a image of nginx
• Copy the vue “dist” directory content to nginx
default directory: /usr/share/nginx renaming it.
• And copy the nginx.conf file (in the root of the
project) to nginx default configuration directory:
/etc/nginx/
27/09/2021 Docker 45
Vue JS Application on Docker
• Now, we need to build the image
• docker build . -t calculator-front-end
• After that, we create a network and run the docker container
• This same network will be used by the back end container
• docker network create calculator-net
• docker run -d -p 8080:8080 –network=calculator-net calculator-front-end
27/09/2021 Docker 46
Vue JS Application on Docker
• When the container goes up, the ningx server will goes up also and make
deploy of our application following the nginx.conf files
• We can access the application on address: http://localhost:8080/calculator/
27/09/2021 Docker 47
Java Application on Docker
27/09/2021 Docker 48
Java Application on Docker
• We will create a simple Java spring boot back-end application for our
calculator
• We will use Gradle as a build tool.
27/09/2021 Docker 49
Java Application on Docker
• Now we will configure dockerfile file
to create a docker image
• Build Steps:
• Download the gradle image
• Create a workdir
• Copy all files to this workdir
• Run the gradle build
• Executions steps:
• Download JDK 11 image
• Copy and rename the application jar
• Expose the back end port
• Execute the Java application when
container goes up
27/09/2021 Docker 50
Java Application on Docker
• We can build the Java back end image with this command
• docker build . -t calculator-back-end
27/09/2021 Docker 51
Java Application on Docker
• Now we can run the back end Java application with this command
• PS.: The front end application should be already running (previous slides)
• docker run -d -p 8081:8081 –network=calculator-net calculator-back-end
27/09/2021 Docker 52
Java Application on Docker
• If everything was ok, now we have a front end VUE.js application run with
nginx server on a Docker calling a back end Java application run on Docker
also.
27/09/2021 Docker 53
Source Code
• https://github.com/jadsonjs/containers
27/09/2021 Docker 54
27/09/2021 Docker 55
Docker Compose
• Docker Compose is a tool for defining
and running multi-container Docker
applications. With Compose, you can
use a YAML file to configure and start
several docker applications.
• So, create a docker-compose.yaml
file with the follow content
27/09/2021 Docker 56
Docker Compose
• First we define the version and the networks of our containers
• We define a new network to the docker compose create it
27/09/2021 Docker 57
Docker Compose
• Now, we need to define our services (containers)
• The first one is the VUE js front end application.
• It uses the calculator-front-end image in port 8080:8080, using the calculator-net2
network and should starts after back-end container
27/09/2021 Docker 58
Docker Compose
• Now, we need to define our services (containers)
• The second one is the Java back end application.
• It uses the calculator-back-end image in port 8081:8081, using the same calculator-
net2 network.
27/09/2021 Docker 59
Docker Compose
• Now, just execute the follow command:
• docker compose up -d
• This command will replace the follow two commands and simplify the
docker execution
• docker run -d -p 8080:8080 –network=calculator-net calculator-front-end
• docker run -d -p 8081:8081 –network=calculator-net calculator-back-end
• To stop the execution of containers, type:
• docker compose down
27/09/2021 Docker 60
References
• https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-
ubuntu-20-04
• https://cli.vuejs.org/guide/deployment.html#docker-nginx
• https://medium.com/bb-tutorials-and-thoughts/how-to-serve-vue-js-application-with-nginx-
and-docker-d8a872a02ea8
•
https://www.baeldung.com/dockerizing-spring-boot-application
• https://docs.docker.com/language/java/build-images/
27/09/2021 Docker 63
References
• https://medium.com/swlh/spring-boot-with-docker-2467db187fa2
• https://dzone.com/articles/docker-with-spring-boot-how-to
• https://docs.docker.com/compose/
27/09/2021 Docker 64
27/09/2021 Docker 65

Weitere ähnliche Inhalte

Was ist angesagt?

Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Edureka!
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...Simplilearn
 
Dockers and containers basics
Dockers and containers basicsDockers and containers basics
Dockers and containers basicsSourabh Saxena
 
Using AWS, Terraform, and Ansible to Automate Splunk at Scale
Using AWS, Terraform, and Ansible to Automate Splunk at ScaleUsing AWS, Terraform, and Ansible to Automate Splunk at Scale
Using AWS, Terraform, and Ansible to Automate Splunk at ScaleData Works MD
 
Infrastructure as Code with Ansible
Infrastructure as Code with AnsibleInfrastructure as Code with Ansible
Infrastructure as Code with AnsibleDaniel Bezerra
 
Building Kubernetes images at scale with Tanzu Build Service
Building Kubernetes images at scale with Tanzu Build ServiceBuilding Kubernetes images at scale with Tanzu Build Service
Building Kubernetes images at scale with Tanzu Build ServiceVMware Tanzu
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefitsAmit Manwade
 
The virtual DOM and how react uses it internally
The virtual DOM and how react uses it internallyThe virtual DOM and how react uses it internally
The virtual DOM and how react uses it internallyClĂłvis Neto
 
INF107 - Integrating HCL Domino and Microsoft 365
INF107 - Integrating HCL Domino and Microsoft 365INF107 - Integrating HCL Domino and Microsoft 365
INF107 - Integrating HCL Domino and Microsoft 365Dylan Redfield
 
3.ahn report를 이용한 악성코드 대응
3.ahn report를 이용한 악성코드 대응3.ahn report를 이용한 악성코드 대응
3.ahn report를 이용한 악성코드 대응Youngjun Chang
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker, Inc.
 
The Benefits of Using React JS for Web Development!
The Benefits of Using React JS for Web Development!The Benefits of Using React JS for Web Development!
The Benefits of Using React JS for Web Development!Baharika Sopori
 
Introduction to Docker - 2017
Introduction to Docker - 2017Introduction to Docker - 2017
Introduction to Docker - 2017Docker, Inc.
 
Introduction of Cloud computing
Introduction of Cloud computingIntroduction of Cloud computing
Introduction of Cloud computingRkrishna Mishra
 
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...Majid Hajibaba
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...Edureka!
 
Configuring Domino To Be An Ldap Directory And To Use An Ldap Directory
Configuring Domino To Be An Ldap Directory And To Use An Ldap DirectoryConfiguring Domino To Be An Ldap Directory And To Use An Ldap Directory
Configuring Domino To Be An Ldap Directory And To Use An Ldap DirectoryEdson Oliveira
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Herofazalraja
 
Java EE 7 Batch processing in the Real World
Java EE 7 Batch processing in the Real WorldJava EE 7 Batch processing in the Real World
Java EE 7 Batch processing in the Real WorldRoberto Cortez
 

Was ist angesagt? (20)

Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
 
Dockers and containers basics
Dockers and containers basicsDockers and containers basics
Dockers and containers basics
 
Using AWS, Terraform, and Ansible to Automate Splunk at Scale
Using AWS, Terraform, and Ansible to Automate Splunk at ScaleUsing AWS, Terraform, and Ansible to Automate Splunk at Scale
Using AWS, Terraform, and Ansible to Automate Splunk at Scale
 
Infrastructure as Code with Ansible
Infrastructure as Code with AnsibleInfrastructure as Code with Ansible
Infrastructure as Code with Ansible
 
Building Kubernetes images at scale with Tanzu Build Service
Building Kubernetes images at scale with Tanzu Build ServiceBuilding Kubernetes images at scale with Tanzu Build Service
Building Kubernetes images at scale with Tanzu Build Service
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefits
 
The virtual DOM and how react uses it internally
The virtual DOM and how react uses it internallyThe virtual DOM and how react uses it internally
The virtual DOM and how react uses it internally
 
Daos
DaosDaos
Daos
 
INF107 - Integrating HCL Domino and Microsoft 365
INF107 - Integrating HCL Domino and Microsoft 365INF107 - Integrating HCL Domino and Microsoft 365
INF107 - Integrating HCL Domino and Microsoft 365
 
3.ahn report를 이용한 악성코드 대응
3.ahn report를 이용한 악성코드 대응3.ahn report를 이용한 악성코드 대응
3.ahn report를 이용한 악성코드 대응
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016
 
The Benefits of Using React JS for Web Development!
The Benefits of Using React JS for Web Development!The Benefits of Using React JS for Web Development!
The Benefits of Using React JS for Web Development!
 
Introduction to Docker - 2017
Introduction to Docker - 2017Introduction to Docker - 2017
Introduction to Docker - 2017
 
Introduction of Cloud computing
Introduction of Cloud computingIntroduction of Cloud computing
Introduction of Cloud computing
 
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
Cloud Computing Principles and Paradigms: 7 enhancing cloud computing environ...
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
 
Configuring Domino To Be An Ldap Directory And To Use An Ldap Directory
Configuring Domino To Be An Ldap Directory And To Use An Ldap DirectoryConfiguring Domino To Be An Ldap Directory And To Use An Ldap Directory
Configuring Domino To Be An Ldap Directory And To Use An Ldap Directory
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Java EE 7 Batch processing in the Real World
Java EE 7 Batch processing in the Real WorldJava EE 7 Batch processing in the Real World
Java EE 7 Batch processing in the Real World
 

Ähnlich wie Containerizing a Web Application with Vue.js and Java

Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and MicroserviceSamuel Chow
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes IstioAraf Karsh Hamid
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From ScratchGiacomo Vacca
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with dockerMichelle Liu
 
IBM WebSphere Application Server traditional and Docker
IBM WebSphere Application Server traditional and DockerIBM WebSphere Application Server traditional and Docker
IBM WebSphere Application Server traditional and DockerDavid Currie
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX ContainerAraf Karsh Hamid
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with DockerGeeta Vinnakota
 
14309525_docker_docker_docker_docker_introduction.ppt
14309525_docker_docker_docker_docker_introduction.ppt14309525_docker_docker_docker_docker_introduction.ppt
14309525_docker_docker_docker_docker_introduction.pptaravym456
 
Introduction to Containers & Diving a little deeper into the benefits of Con...
 Introduction to Containers & Diving a little deeper into the benefits of Con... Introduction to Containers & Diving a little deeper into the benefits of Con...
Introduction to Containers & Diving a little deeper into the benefits of Con...Synergetics Learning and Cloud Consulting
 
Introduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUGIntroduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUGAjeet Singh Raina
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101Naukri.com
 
Let's dockerize
Let's dockerizeLet's dockerize
Let's dockerizeAhmed Sorour
 
Introduction to Docker Containers - Docker Captain
Introduction to Docker Containers - Docker CaptainIntroduction to Docker Containers - Docker Captain
Introduction to Docker Containers - Docker CaptainAjeet Singh Raina
 
Intro docker and demo monitor on docker
Intro docker and demo monitor on dockerIntro docker and demo monitor on docker
Intro docker and demo monitor on dockerWatcharin Yang-Ngam
 
The Docker Ecosystem
The Docker EcosystemThe Docker Ecosystem
The Docker EcosystemDmitry Skaredov
 
Virtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesVirtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesabhishek chawla
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for DevelopersJasonStraughan1
 
Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentalsAlper Unal
 

Ähnlich wie Containerizing a Web Application with Vue.js and Java (20)

Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Docker slides
Docker slidesDocker slides
Docker slides
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
 
IBM WebSphere Application Server traditional and Docker
IBM WebSphere Application Server traditional and DockerIBM WebSphere Application Server traditional and Docker
IBM WebSphere Application Server traditional and Docker
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Docker
DockerDocker
Docker
 
14309525_docker_docker_docker_docker_introduction.ppt
14309525_docker_docker_docker_docker_introduction.ppt14309525_docker_docker_docker_docker_introduction.ppt
14309525_docker_docker_docker_docker_introduction.ppt
 
Introduction to Containers & Diving a little deeper into the benefits of Con...
 Introduction to Containers & Diving a little deeper into the benefits of Con... Introduction to Containers & Diving a little deeper into the benefits of Con...
Introduction to Containers & Diving a little deeper into the benefits of Con...
 
Introduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUGIntroduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUG
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 
Let's dockerize
Let's dockerizeLet's dockerize
Let's dockerize
 
Introduction to Docker Containers - Docker Captain
Introduction to Docker Containers - Docker CaptainIntroduction to Docker Containers - Docker Captain
Introduction to Docker Containers - Docker Captain
 
Intro docker and demo monitor on docker
Intro docker and demo monitor on dockerIntro docker and demo monitor on docker
Intro docker and demo monitor on docker
 
The Docker Ecosystem
The Docker EcosystemThe Docker Ecosystem
The Docker Ecosystem
 
Virtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesVirtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management services
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentals
 

Mehr von Jadson Santos

A Deep Dive into Continuous Integration Monitoring Practices
A Deep Dive into Continuous Integration Monitoring PracticesA Deep Dive into Continuous Integration Monitoring Practices
A Deep Dive into Continuous Integration Monitoring PracticesJadson Santos
 
Continuous Delivery with Jenkins
Continuous Delivery with JenkinsContinuous Delivery with Jenkins
Continuous Delivery with JenkinsJadson Santos
 
Cd with Github Travis CI and Heroku
Cd with Github Travis CI and HerokuCd with Github Travis CI and Heroku
Cd with Github Travis CI and HerokuJadson Santos
 
Jenkins Continuous Delivery
Jenkins Continuous DeliveryJenkins Continuous Delivery
Jenkins Continuous DeliveryJadson Santos
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
Hazelcast Distributed Lock
Hazelcast Distributed LockHazelcast Distributed Lock
Hazelcast Distributed LockJadson Santos
 
Testes Unitários
Testes UnitáriosTestes Unitários
Testes UnitáriosJadson Santos
 
Introdução ao Flyway
Introdução ao FlywayIntrodução ao Flyway
Introdução ao FlywayJadson Santos
 
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse - I...
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse  -  I...Mini curso gerenciamento de configuração e mudança com GIT + Eclipse  -  I...
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse - I...Jadson Santos
 
Usando hiberante de forma otimizada
Usando hiberante de forma otimizadaUsando hiberante de forma otimizada
Usando hiberante de forma otimizadaJadson Santos
 
Usando JMeter para testar sua aplicação JSF
Usando JMeter para testar sua aplicação JSFUsando JMeter para testar sua aplicação JSF
Usando JMeter para testar sua aplicação JSFJadson Santos
 
ICEIS 2013 Presentation
ICEIS 2013 PresentationICEIS 2013 Presentation
ICEIS 2013 PresentationJadson Santos
 
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...Jadson Santos
 

Mehr von Jadson Santos (19)

A Deep Dive into Continuous Integration Monitoring Practices
A Deep Dive into Continuous Integration Monitoring PracticesA Deep Dive into Continuous Integration Monitoring Practices
A Deep Dive into Continuous Integration Monitoring Practices
 
Continuous Delivery with Jenkins
Continuous Delivery with JenkinsContinuous Delivery with Jenkins
Continuous Delivery with Jenkins
 
Cd with Github Travis CI and Heroku
Cd with Github Travis CI and HerokuCd with Github Travis CI and Heroku
Cd with Github Travis CI and Heroku
 
Vue.js
Vue.jsVue.js
Vue.js
 
Jenkins Continuous Delivery
Jenkins Continuous DeliveryJenkins Continuous Delivery
Jenkins Continuous Delivery
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Hazelcast Distributed Lock
Hazelcast Distributed LockHazelcast Distributed Lock
Hazelcast Distributed Lock
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Testes Unitários
Testes UnitáriosTestes Unitários
Testes Unitários
 
Java8
Java8Java8
Java8
 
Gradle
GradleGradle
Gradle
 
Git
GitGit
Git
 
Introdução ao Flyway
Introdução ao FlywayIntrodução ao Flyway
Introdução ao Flyway
 
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse - I...
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse  -  I...Mini curso gerenciamento de configuração e mudança com GIT + Eclipse  -  I...
Mini curso gerenciamento de configuração e mudança com GIT + Eclipse - I...
 
Usando hiberante de forma otimizada
Usando hiberante de forma otimizadaUsando hiberante de forma otimizada
Usando hiberante de forma otimizada
 
Usando JMeter para testar sua aplicação JSF
Usando JMeter para testar sua aplicação JSFUsando JMeter para testar sua aplicação JSF
Usando JMeter para testar sua aplicação JSF
 
ICEIS 2013 Presentation
ICEIS 2013 PresentationICEIS 2013 Presentation
ICEIS 2013 Presentation
 
Enums
EnumsEnums
Enums
 
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
Conditional Execution - A Pattern for the Implementation of Fine-Grained Vari...
 

KĂźrzlich hochgeladen

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto GonzĂĄlez Trastoy
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfWilly Marroquin (WillyDevNET)
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

KĂźrzlich hochgeladen (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Containerizing a Web Application with Vue.js and Java

  • 1. Jadson Santos Containerizing a Web Application with Vue.js and Java
  • 2. Container • Seaports before container were a mess 27/09/2021 Docker 2
  • 3. Container • After container, load a ship became faster 27/09/2021 Docker 3
  • 4. Container • How setup the execution environment • 1o Install directly in SO: Very complex, several different configurations • 2o Use virtual machines like VMWare, Virtual Box: memory and processing consumption is too high • 3o Use a container: it's possible to run an application with all the required settings (environment variables, packages, etc.) with minimal impact 27/09/2021 Docker 4
  • 5. Container • Containers isolate microservice processes and applications into smaller instances that utilize only the virtualized operating system rather than the full virtual machine and the entire complement of abstracted hardware that VM includes • For containers, they operate more as fully isolated sandboxes, with only the minimal kernel of the operating system present for each container. 27/09/2021 Docker 5
  • 8. Docker • Docker is a set of platform-as-a-service products that use operating system- level virtualization to deliver software in packages called containers. • Docker do not create the container technology, but was the first tool to let is popular and and relatively easy to use. 27/09/2021 Docker 8 Registry Docker Daemon Containers Images Client docker run docker build docker pull
  • 9. Docker • Client: Client receiving and executes the commands of users • Docker Daemon: Who manages the containers • Registry: Where the images are stored 27/09/2021 Docker 9
  • 10. Installation • Linux • First, install some prerequisite packages that let apt use packages over HTTPS: • sudo apt update sudo apt install apt-transport-https ca-certificates curl software- properties-common • Add the GPG key to the official Docker repository on your system: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - • Add the Docker repository to the APT sources: sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" 27/09/2021 Docker 10
  • 11. Installation • Linux • Then update the database with the Docker packages from the newly added repository: • sudo apt update • Now, install the Docker • sudo apt install docker-ce • Add your username to the docker group: • sudo usermod -aG docker “user” 27/09/2021 Docker 11
  • 12. Installation • Mac OS • Go to https://hub.docker.com/ • Download Docker Desktop for Mac • Docker is native for Linux, to run on Windows and MacOS we need the Docker Desktop 27/09/2021 Docker 12
  • 13. Installation • Mac OS • Type docker version 27/09/2021 Docker 13
  • 14. Docker Introduction • Hello World docker container run hello-world 27/09/2021 Docker 14 image name
  • 15. Docker Introduction • Hello World • There is an image “hello-world” locally? 27/09/2021 Docker 15 Registry Docker Daemon Containers Images Client docker run
  • 16. Docker Introduction • Hello World • Download from registry (https://hub.docker.com/) 27/09/2021 Docker 16 Registry Docker Daemon Containers Images Client docker run
  • 17. Docker Introduction • Hello World • Run the container that is an instance of “hello-world” image 27/09/2021 Docker 17 Registry Docker Daemon Containers Images Client docker run
  • 18. Docker Introduction • Docker hub • Docker hub is the default docker registry • It has unlimited public repositories 27/09/2021 Docker 18
  • 19. Docker Introduction • Docker hub • You can search for images • Give preference to official images 27/09/2021 Docker 19
  • 20. Docker Introduction • Docker hub • Each image has several tags • Choose the image that best fits your application requirements 27/09/2021 Docker 20
  • 21. Docker Introduction • Docker hub • You can install local registry to your company. 27/09/2021 Docker 21
  • 22. Docker Introduction • List the containers running • docker container ls • List all containers • docker container ls -a 27/09/2021 Docker 22
  • 23. Docker Introduction • Give a name to the container • docker container run -–name my_hello_container hello-world 27/09/2021 Docker 23
  • 24. Docker Introduction • Removing a container • docker container rm <ID or NAME> • Restarting the container • docker container restart <ID or NAME> • Stopping the container • docker container stop <ID or NAME> 27/09/2021 Docker 24
  • 25. Docker Introduction • Accessing the container • Download the “ubuntu” image, run the container using this image and give me access the /bin/bash application inside de container • docker container run -it ubuntu /bin/bash • Accessing the container when it is running • docker container exec -it ubuntu /bin/bash 27/09/2021 Docker 25 In this case, the application argument stay after image name, in the other cases, image name is always the last argument of command
  • 26. Docker Port Binding • To have access an application running inside the container, it is necessary to define a port from the port bind. In the format HOST : CONTAINER • docker container run -p 27017:27017 mongo 27/09/2021 Docker 26 Bing the mongo DB 27017 port (mongo db goes up inside de container) to the 27017 HOST port HOST : Mongo DB
  • 27. Docker Images • Docker images act as a template to build a Docker container. • Docker images contains layers that install libraries, tools, dependences, files needed to make your application run. • Docker images layers increase reusability, decrease disk usage, and speed up docker build by allowing each step to be cached. • We need to create an image containing our application to run it on a Docker 27/09/2021 Docker 27 Image Layer 01 Layer 02 Layer 03 Layer 04 Layer N
  • 28. Docker Images • The easiest way to create an image is via the Dockerfile file • Example of Dockerfile of a simple Node application 27/09/2021 Docker 28
  • 29. Docker Images • The easiest way to create an image is via the Dockerfile file • Example of Dockerfile of a simple Node application 27/09/2021 Docker 29
  • 30. Docker Images • The easiest way to create an image is via the Dockerfile file • Starting downloading a node image • Create a working directory (WORKDIR == “mkdir /app” and “cd /app”) • Copies the .package.json and .package-lock.json file • Run “npm install” to download and install node dependencies • Copy the other files of project • When the container goes up, execute the command “node app.js" 27/09/2021 Docker 30
  • 31. Docker Images • Build a image with your node application • docker build . -t jadsonjs/appnode:v1 27/09/2021 Docker 31 Image name (name space + repository + tag)
  • 32. Docker Images • List the images docker image ls 27/09/2021 Docker 32
  • 33. Docker Images • Execute your node application inside the docker docker container run –d –p 8080:8081 -–name my_appnode_container jadsonjs/appnode:v1 docker container ls 27/09/2021 Docker 33 Image name Container name Run in background Bind the 8081 NODE application port to 8080 HOST port
  • 34. Docker Images • Execute your node application inside the docker 27/09/2021 Docker 34
  • 35. Docker Images • Publish image to docker hub • Publish the image to my account do docker hub as a public image that other people can use. docker login docker push jadsonjs/appnode:v1 27/09/2021 Docker 35
  • 36. Docker Images • Publish image to docker hub • Publish the image to my account do docker hub as a public image that other people can use. 27/09/2021 Docker 36
  • 37. Docker Networks • If you are going to run 2 or more applications in 2 or more separate containers and need them to communicate. Must create a network between these containers docker network create my-app-net docker container run -–name api –d -p 8080:8080 -–network=my-app-net jadsonjs/appnode:v1 docker container run -–name mongodb -d -p 27017:27017 -e USER=user -e PASS=1234 -–network=my-app-net mongo:5.0.3 27/09/2021 Docker 37
  • 38. Docker Volumes • Used to save data if you kill and upload the container again. Example: Container of a database. • Link container file system with the host file system • This can be done via directory bind. In the format HOST : CONTAINER, similar with port bind docker container run -–name bancoDeDadosMongo -d -p 27017:27017 -e USER=user -e PASS=1234 -–network=api-net -v “/usr/local/mongodb:/data/db” mongo:5.0.3 27/09/2021 Docker 38 Bind the /data/db mongo db directory with /usr/local/mongodb HOST directory In other words, the data will be save in /usr/local/mongodb HOST directory
  • 39. Docker Volumes • Creating a volume docker volume create mongodb_vol docker container run -–name mongodb -d -p 27017:27017 -e USER=user -e PASS=1234 -–network=my-app-net -v “mongodb_vol:/data/db” mongo:5.0.3 27/09/2021 Docker 39 Bind the /data/db mongo db directory with a mongodb_vol create by the container mongodb_vol is a directory in HOST machine created and managed by container
  • 40. Docker Volumes • Creating a volume docker volume ls docker volume inspect mongo_db_vol 27/09/2021 Docker 40
  • 41. Vue JS Application on Docker 27/09/2021 Docker 41
  • 42. Vue JS Application on Docker • Let’s create a simple VUE calculator application with de command • vue create calculator-front-end • The application will be a simple calculator that will call a back-end application written in Java. • The front end application will be deployed using nginx server. • The back end application will be deployed in another Docker container. 27/09/2021 Docker 42
  • 43. Vue JS Application on Docker • Let’s create a simple VUE calculator application • We create a nginx.conf file in the project root that configure your “calculator” application • When somebody type “/calculator” on url, the nginx serve should execute the /calculator/index.html of a VUE Single Page Application project • This file will be copy into the container file system. 27/09/2021 Docker 43
  • 44. Vue JS Application on Docker • Let’s create a simple VUE calculator application • For the vue app work inside nginx server, we have to define a context to VUE application when execute on Docker, we make this in the vue.config.js file. 27/09/2021 Docker 44
  • 45. Vue JS Application on Docker • In the dockerfile file, we define some steps to build our image • Build Steps: • Download a “node” image • Create a temp directory “app” and copy package*.json files to it • Install all Vue dependences • Copy the other files and make the build of project • Execution Steps: • Now, download a image of nginx • Copy the vue “dist” directory content to nginx default directory: /usr/share/nginx renaming it. • And copy the nginx.conf file (in the root of the project) to nginx default configuration directory: /etc/nginx/ 27/09/2021 Docker 45
  • 46. Vue JS Application on Docker • Now, we need to build the image • docker build . -t calculator-front-end • After that, we create a network and run the docker container • This same network will be used by the back end container • docker network create calculator-net • docker run -d -p 8080:8080 –network=calculator-net calculator-front-end 27/09/2021 Docker 46
  • 47. Vue JS Application on Docker • When the container goes up, the ningx server will goes up also and make deploy of our application following the nginx.conf files • We can access the application on address: http://localhost:8080/calculator/ 27/09/2021 Docker 47
  • 48. Java Application on Docker 27/09/2021 Docker 48
  • 49. Java Application on Docker • We will create a simple Java spring boot back-end application for our calculator • We will use Gradle as a build tool. 27/09/2021 Docker 49
  • 50. Java Application on Docker • Now we will configure dockerfile file to create a docker image • Build Steps: • Download the gradle image • Create a workdir • Copy all files to this workdir • Run the gradle build • Executions steps: • Download JDK 11 image • Copy and rename the application jar • Expose the back end port • Execute the Java application when container goes up 27/09/2021 Docker 50
  • 51. Java Application on Docker • We can build the Java back end image with this command • docker build . -t calculator-back-end 27/09/2021 Docker 51
  • 52. Java Application on Docker • Now we can run the back end Java application with this command • PS.: The front end application should be already running (previous slides) • docker run -d -p 8081:8081 –network=calculator-net calculator-back-end 27/09/2021 Docker 52
  • 53. Java Application on Docker • If everything was ok, now we have a front end VUE.js application run with nginx server on a Docker calling a back end Java application run on Docker also. 27/09/2021 Docker 53
  • 56. Docker Compose • Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you can use a YAML file to configure and start several docker applications. • So, create a docker-compose.yaml file with the follow content 27/09/2021 Docker 56
  • 57. Docker Compose • First we define the version and the networks of our containers • We define a new network to the docker compose create it 27/09/2021 Docker 57
  • 58. Docker Compose • Now, we need to define our services (containers) • The first one is the VUE js front end application. • It uses the calculator-front-end image in port 8080:8080, using the calculator-net2 network and should starts after back-end container 27/09/2021 Docker 58
  • 59. Docker Compose • Now, we need to define our services (containers) • The second one is the Java back end application. • It uses the calculator-back-end image in port 8081:8081, using the same calculator- net2 network. 27/09/2021 Docker 59
  • 60. Docker Compose • Now, just execute the follow command: • docker compose up -d • This command will replace the follow two commands and simplify the docker execution • docker run -d -p 8080:8080 –network=calculator-net calculator-front-end • docker run -d -p 8081:8081 –network=calculator-net calculator-back-end • To stop the execution of containers, type: • docker compose down 27/09/2021 Docker 60
  • 61. References • https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on- ubuntu-20-04 • https://cli.vuejs.org/guide/deployment.html#docker-nginx • https://medium.com/bb-tutorials-and-thoughts/how-to-serve-vue-js-application-with-nginx- and-docker-d8a872a02ea8 • https://www.baeldung.com/dockerizing-spring-boot-application • https://docs.docker.com/language/java/build-images/ 27/09/2021 Docker 63