DevOps 1
DevOps 1
DevOps
2
DevOps - History
3
DevOps - Overview
4
Relationship between Agile and DevOps
5
6
7
8
9
10
11
12
13
14
15
Introduction To
Containerisation
Before Docker
17
Result
18
Eg: Oracle WebLogic Software
19
Solution 1: Virtual Machine
20
What is VM?
21
Solution 2: Container
22
Docker By Mirantis
23
▸ Docker is an open-source Platform that helps the user to package an
application and its dependencies into a Docker Container for the Development
and Deployment of Software.
▸ Containerisation includes all dependencies (libraries, frameworks etc..)
required to run an application in an efficient and bug-free manner.
▸ With Docker containers, applications can work efficiently in different
computer environments.
24
With Docker
25
VM vs Container
26
VM vs Container
27
Containerisation
28
Advantages
29
Why Docker?
30
Docker Architecture
31
32
33
34
35
36
37
38
Docker Container Lifecycle
Dockerize your Application
▸ A Dockerfile is a fundamental building block used when dockerizing your Java
applications, and it is how you can create a Docker image that can be used to
create the containers you need for automatic builds.
▸ Introduction to Dockerfiles
▸ Docker builds images by reading instructions from a Dockerfile. A Dockerfile is a
simple text file that contains instructions that can be executed on the command
line. Using docker build, you can start a build that executes all of the command-
line instructions contained in the Dockerfile.
40
YAML
▸ YAML Ain't Markup Language (YAML) is a serialization language that has steadily
increased in popularity over the last few years. It's often used as a format for
configuration files, but its object serialization abilities make it a viable
replacement for languages like JSON.
▸ YAML has broad language support and maps easily into native data structures.
It's also easy to for humans to read, which is why it's a good choice for
configuration.
▸ The YAML acronym was shorthand for Yet Another Markup Language. But the
maintainers renamed it to YAML Ain't Markup Language to place more emphasis
on its data-oriented features.
41
▸ Common Dockerfile instructions start with RUN, ENV, FROM, MAINTAINER, ADD,
and CMD, among others.
▸ FROM - Specifies the base image that the Dockerfile will use to build a new image. For this
post, we are using phusion/baseimage as our base image because it is a minimal Ubuntu-
based image modified for Docker friendliness.
▸ MAINTAINER - Specifies the Dockerfile Author Name and his/her email.
▸ RUN - Runs any UNIX command to build the image.
▸ ENV - Sets the environment variables. For this post, JAVA_HOME is the variable that is
set.
▸ CMD - Provides the facility to run commands at the start of container. This can be
overridden upon executing the docker run command.
▸ ADD - This instruction copies the new files, directories into the Docker container file
system at specified destination.
▸ EXPOSE - This instruction exposes specified port to the host machine.
42
Installing Docker Desktop
▸ https://docs.docker.com/desktop/install/windows-install/
▸ Double-click Docker Desktop Installer.exe to run the installer.
▸ When prompted, ensure the Use WSL 2 instead of Hyper-V option on the Configuration
page is selected or not depending on your choice of backend.
▸ Follow the instructions on the installation wizard to authorize the installer and proceed
with the install.
▸ When the installation is successful, click Close to complete the installation process.
▸ If your admin account is different to your user account, you must add the user to the
docker-users group. Run Computer Management as an administrator and navigate to
Local Users and Groups > Groups > docker-users. Right-click to add the user to the group.
Log out and log back in for the changes to take effect.
43
Start Docker Desktop
▸ Docker Desktop does not start automatically after installation. To start Docker
Desktop:
▸ Search for Docker, and select Docker Desktop in the search results.
44
The Docker Dashboard
▸ A container is a sandboxed process on
your machine that is isolated from all
other processes on the host machine.
▹ is a runnable instance of an image.
You can create, start, stop, move, or
delete a container using the
DockerAPI or CLI.
▹ can be run on local machines, virtual
machines or deployed to the cloud.
▹ is portable (can be run on any OS).
▹ is isolated from other containers
and runs its own software, binaries,
and configurations.
45
Running your first container
▸ At first, we are going to run an Alpine Linux container (a lightweight linux
distribution) on your system and get a taste of the docker run command.
▸ To get started, let's run the following in our terminal:
▸ docker pull alpine
▸ The pull command fetches the alpine image from the Docker registry and saves
it in our system. You can use the docker images command to see a list of all
images on your system.
▸ Let's now run a Docker container based on this image. To do that you are going to use the
docker run command.
▸ docker run alpine ls -l
46
What happened? Behind the scenes, a lot of stuff happened. When you call run,
47
Run a static website in a container
▸ First, we'll use Docker to run a static website in a container. The website is based on an
existing image. We'll pull a Docker image from Docker Store, run the container, and see
how easy it is to set up a web server.
▸ The image that you are going to use is a single-page website that was already created for
this demo and is available on the Docker Store as dockersamples/static-site. You can
download and run the image directly in one go using docker run as follows.
▸ docker run -d dockersamples/static-site
So, what happens when you run this command?
▸ Since the image doesn't exist on your Docker host, the Docker daemon first fetches it
from the registry and then runs it as a container.
▸ Now that the server is running, do you see the website? What port is it running on? And
more importantly, how do you access the container directly from our host machine?
48
▸ First, stop the container that you have just launched. In order to do this, we need the
container ID.
▸ Since we ran the container in detached mode, we don't have to launch another terminal to
do this. Run docker ps to view the running containers.
▸ Check out the CONTAINER ID column. You will need to use this CONTAINER ID value, a long
sequence of characters, to identify the container you want to stop, and then to remove it.
The example below provides the CONTAINER ID on our system; you should use the value that
you see in your terminal.
▸ docker stop 0d9ae56459f4
▸ docker rm 0d9ae56459f4
▸ Now, let's launch a container in detached mode as shown below:
▸ docker run --name static-site -e AUTHOR="Your Name" -d -P dockersamples/static-site
49
▸ -d will create a container with the process detached from our terminal
▸ -P will publish all the exposed container ports to random ports on the Docker host
▸ -e is how you pass environment variables to the container
▸ --name allows you to specify a container name
▸ AUTHOR is the environment variable name and Your Name is the value that you can pass
Now you can see the ports by running the docker port command.
▸ docker port static-site
▸ You can now open http://localhost:49154/, if the port is 49154.
▸ You can also run a second webserver at the same time, specifying a custom host port
mapping to the container's webserver.
▸ docker run --name static-site-2 -e AUTHOR=“Sunitha" -d -p 8888:80
dockersamples/static-site
▸ To deploy this on a real server you would just need to install Docker, and run the above docker
command(as in this case you can see the AUTHOR is Docker which we passed as an
environment variable).
50
Questions ???
51