SlideShare une entreprise Scribd logo
1  sur  53
Télécharger pour lire hors ligne
Workshop
Jirayut Nimsaeng (Dear)
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
#whoami
● Jirayut Nimsaeng (Dear)
● The Builder at
● Interested in Cloud and
Open Source Technology
● Agile Practitioner and
ScrumMaster with
DevOps Driven Development
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Developer Problems
Developer Local Test QA
Production
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
What Developer needs
Production-like Quick Repeatable
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker can solve this problem
Developer Local Test QA
Production
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker can
● Deploy (almost) everything
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker can
● Deploy (almost) everywhere
Native On VMs
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
What is Docker?
● Service Platform to help code, test and deploy
applications
● Combine with
– Lightweight container virtualization
– Work flows
– Tooling
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker Containers as a Service Platform
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Containers vs. VMs
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker image
● Docker images are read-only templates
● Each image consists of series of layers
● Docker use union file system to combine layers
into single image
● Every image starts from base image
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker image layers
http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker container
● A container is defined as a "union view" of a stack
of layers the top of which is a read-write layer.
http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Image vs Container
Docker Image is a class
Docker Container is a instance of class
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Image vs Container
http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Running Container
http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Dockerfile
● Dockerfile is instructions to build Docker image
– How to run commands
– Add files or directories
– Create environment variables
– What process to run when launching container
● Result from building Dockerfile is Docker image
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Sample Dockerfile
FROM ubuntu:14.04
MAINTAINER Jirayut Nimsaeng <w [at] winginfotech.net>
ADD build-files /build-files
RUN apt-get update
RUN apt-get install -y openssh-server vim tmux rsync byobu
RUN mkdir /var/run/sshd
RUN sed -i 's/required pam_loginuid.so/optional
pam_loginuid.so/g' /etc/pam.d/sshd
CMD /start.sh
EXPOSE 22
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker Registry
● Docker Registry is the store for Docker image
● Docker Hub is public Docker Registry like Github
● Using Docker client to push and pull Docker image
from Docker Registry
● You can create your own Docker Registry with
Docker Distribution
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker Hub
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker workflows
Dockerfile
For App A
Host 1 (Dev/Build Server)
Docker Engine
ImageAppAImageAppA
Docker
Registry
Host 2 (Container Server)
1.Build
2.Push
3.Pull
4.Run
Docker Engine
ImageAppA
ContainerAppAProduction
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker Installation
● Docker Toolbox for Mac and Windows
– https://www.docker.com/toolbox
– All-in-one Docker installation
● Docker Engine
● Docker Machine
● Docker Compose
● Docker Kitematic
● VirtualBox
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker installation
● Ubuntu based
– https://docs.docker.com/installation/ubuntulinux/
– Recommend Ubuntu 14.04 64-bit LTS or up
– curl -sSL https://get.docker.com/ | sudo sh
● Redhat based
– https://docs.docker.com/installation/centos/
– Recommend CentOS 7
– curl -sSL https://get.docker.com/ | sh
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker architecture
Host
Docker Engine
Web Server
80 xxxx
Docker Containers
Database
Docker Client
socket
3306
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Boot2docker architecture
Host
Virtualbox VM
Docker Engine
Web Server
boot2docker-vm
80 1024+
Docker Containers
Database
2376
Host-only
80
80
3306
Docker Client
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Know the tools (1)
● Docker Client / Engine
Host
Virtualbox VM
Docker Engine
Web Server
boot2docker-vm
80 1024+
Docker Containers
Database
2376
Host-only
80
80
3306
Docker Client
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Know the tools (2)
● Docker Machine
– Lets you create Docker hosts on your computer, on
cloud providers, or inside your own data center
– Automated these steps
● Create Docker host
● Install Docker
● Configure Docker client to talk with server
– Manage Docker multiple Docker host
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Know the tools (3)
● VirtualBox
– Virtualization software to run Docker host
for Mac and Windows
– VM has been configured and managed
by Docker Machine
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Know the tools (4)
● Docker Kitematic
– Simple application for managing Docker containers on
Mac and Windows
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Know the tools (5)
● Docker Compose
– Tool for defining and running multi-container
applications with Docker in a single file
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker Image name
● Official Docker Image
– ubuntu:latest
– centos:centos7
● User's Docker Image on Docker Hub
– google/cadvisor:0.5.0
– dockerfile/mongodb
● Docker Image on Private Docker Registry
– r.winginfotech.net/ubuntu:14.10
– r:5000/docker-registry
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Run first Docker container
● docker images
● docker pull r.winginfotech.net/ubuntu
● docker images
● docker run r.winginfotech.net/ubuntu echo “Hello World”
●
docker run -i -t r.winginfotech.net/ubuntu bash
– whoami
– hostname
– cat /etc/*release*
– exit
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker basic operations
● docker pull [name[:tag]]
– docker pull r.winginfotech.net/centos
– docker pull ubuntu:latest
● docker run [-itd] [name[:tag]] [command]
● docker ps
● docker ps -a
● docker rm [name or cid]
● docker rm [part of cid]
● docker images
● docker rmi [name:tag or iid]
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Image name and tag
● docker pull r.winginfotech.net/ubuntu
● docker images
● docker pull r.winginfotech.net/ubuntu:15.10
● docker images
● docker pull r.winginfotech.net/ubuntu:14.04
● docker images
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Create your first image
●
docker run -it r.winginfotech.net/ubuntu bash
– vim
– echo 'Acquire::http::Proxy "http://r.winginfotech.net:3142";' >
/etc/apt/apt.conf.d/11proxy
– apt-get update
– apt-get install -y vim
– touch vim-installed
– ls
– exit
● docker ps -a
● docker commit [cid] ubuntu-vim
● docker images
● docker run -it ubuntu-vim bash
– ls
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker commit
● Commit takes a container's top-level read-write
layer and burns it into a read-only layer.
● This turns a container into an immutable image.
http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Expose ports
● docker run -it -p 80:80 ubuntu-vim bash
– apt-get install -y apache2
– service apache2 start
– Go to browser: http://ipaddress
– exit
● Commit your apache2 container as
ubuntu-apache2 with tag 14.04 and latest
● Make sure that new images have apache2
● Clear your stopped containers
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Run as daemon & expose port option
●
docker run ubuntu-apache2
●
docker run -d ubuntu-apache2 service apache2 start
●
docker run -d ubuntu-apache2 apachectl
-DFOREGROUND
●
docker run -d -p 80:80 ubuntu-apache2 apachectl
-DFOREGROUND
●
docker run -d -p 8880:80 ubuntu-apache2 apachectl
-DFOREGROUND
●
docker run -d -p 80 ubuntu-apache2 apachectl
-DFOREGROUND
●
docker ps
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker container operation
● docker ps
● docker stop [container id or name]
● docker start [container id or name]
● docker kill [container id or name]
● docker logs [container id or name]
● docker diff [container id or name]
● docker top [container id or name]
● docker inspect [container id or name]
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Some useful command & parameter
● docker run --name my-nginx -d -p 80:80 r.winginfotech.net/nginx
● docker ps
● docker exec -it my-nginx /bin/bash
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Linking
Host
Web Server
80
80
Docker Containers
Database
3306
3306
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Linking
Host
Web Server
80
80
Docker Containers
Database
Linking
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Running Wordpress without linking
● docker run -d –-name wp_mysql -p 3306:3306 
-e MYSQL_ROOT_PASSWORD=mypass 
r.winginfotech.net/mysql
● docker run -d –-name wp -p 80:80 
-e WORDPRESS_DB_PASSWORD=mypass 
-e WORDPRESS_DB_HOST=your-ip-address:3306 
r.winginfotech.net/wordpress
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Running Wordpress with linking
● docker run -d –-name wp_mysql 
-e MYSQL_ROOT_PASSWORD=mypass 
r.winginfotech.net/mysql
● docker run -d –-name wp -p 80:80 
-e WORDPRESS_DB_PASSWORD=mypass 
--link wp_mysql:mysql 
r.winginfotech.net/wordpress
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Data in Container (1)
● Default
https://kvaes.wordpress.com/2016/02/11/docker-storage-patterns-for-persistence/
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Data in Container (2)
● Data Volume
https://kvaes.wordpress.com/2016/02/11/docker-storage-patterns-for-persistence/
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Data in Container (3)
● Data Only Container
https://kvaes.wordpress.com/2016/02/11/docker-storage-patterns-for-persistence/
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Data in Container (4)
● Host Mapped Volume
https://kvaes.wordpress.com/2016/02/11/docker-storage-patterns-for-persistence/
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Running Wordpress with volume
● docker run -d –-name wp_mysql 
-e MYSQL_ROOT_PASSWORD=mypass 
r.winginfotech.net/mysql
● docker run -d –-name wp -p 80:80 
-e WORDPRESS_DB_PASSWORD=mypass 
--link wp_mysql:mysql 
--volumes $(pwd)/uploads:/var/www/html/wp-content/uploads 
r.winginfotech.net/wordpress
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker Compose
●
Create docker-compose.yml file
wordpress:
image: r.winginfotech.net/wordpress
ports:
- "80:80"
links:
- db:mysql
db:
image: r.winginfotech.net/mysql
environment:
MYSQL_ROOT_PASSWORD: mypass
●
docker-compose up
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Play with Docker Compose
● docker-compose up
● docker-compose start
● docker-compose ps
● docker-compose stop
● docker-compose up -d
● docker-compose rm
● docker-compose down
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Simple Voting Application
https://github.com/docker/docker-birthday-3/
Jirayut Nimsaeng
Docker Workshop for beginner
March 20, 2016 @ Odd-e Thailand
Docker build
● Docker build is iteratively runs multiple commands
at once.
http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html

Contenu connexe

Tendances

Tendances (20)

Dockerize the World
Dockerize the WorldDockerize the World
Dockerize the World
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
GDG-ANDROID-ATHENS Meetup: Build in Docker with Jenkins
GDG-ANDROID-ATHENS Meetup: Build in Docker with Jenkins GDG-ANDROID-ATHENS Meetup: Build in Docker with Jenkins
GDG-ANDROID-ATHENS Meetup: Build in Docker with Jenkins
 
Continuous delivery with jenkins, docker and exoscale
Continuous delivery with jenkins, docker and exoscaleContinuous delivery with jenkins, docker and exoscale
Continuous delivery with jenkins, docker and exoscale
 
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes
Using Docker to Develop, Test and Run Maven Projects - Wouter DanesUsing Docker to Develop, Test and Run Maven Projects - Wouter Danes
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes
 
Docker for PHP Developers (NomadPHP)
Docker for PHP Developers (NomadPHP)Docker for PHP Developers (NomadPHP)
Docker for PHP Developers (NomadPHP)
 
Dev to Delivery with Puppet, Vagrant and AWS
Dev to Delivery with Puppet, Vagrant and AWSDev to Delivery with Puppet, Vagrant and AWS
Dev to Delivery with Puppet, Vagrant and AWS
 
JOSA TechTalk: Taking Docker to Production
JOSA TechTalk: Taking Docker to ProductionJOSA TechTalk: Taking Docker to Production
JOSA TechTalk: Taking Docker to Production
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
Automate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOpsAutomate App Container Delivery with CI/CD and DevOps
Automate App Container Delivery with CI/CD and DevOps
 
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices Workshop
 
Arnaud Porterie - Using Machine & Docker to develop & build Docker
Arnaud Porterie - Using Machine & Docker to develop & build DockerArnaud Porterie - Using Machine & Docker to develop & build Docker
Arnaud Porterie - Using Machine & Docker to develop & build Docker
 
Testing cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTestTesting cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTest
 
Drone CI
Drone CIDrone CI
Drone CI
 
Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015Import golang; struct microservice - Codemotion Rome 2015
Import golang; struct microservice - Codemotion Rome 2015
 
Podman, Buildah, and Quarkus - The Latest in Linux Containers Technologies
Podman, Buildah, and Quarkus - The Latest in Linux Containers Technologies Podman, Buildah, and Quarkus - The Latest in Linux Containers Technologies
Podman, Buildah, and Quarkus - The Latest in Linux Containers Technologies
 
Docker for Integration Testing
Docker for Integration TestingDocker for Integration Testing
Docker for Integration Testing
 
GDGSCL - Docker a jeho provoz v Heroku a AWS
GDGSCL - Docker a jeho provoz v Heroku a AWSGDGSCL - Docker a jeho provoz v Heroku a AWS
GDGSCL - Docker a jeho provoz v Heroku a AWS
 
[HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes]
[HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes][HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes]
[HKOSCON][20190615][DevOps with Ansible, From Native to Kubernetes]
 

En vedette

Docker workshop
Docker workshopDocker workshop
Docker workshop
Evans Ye
 
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
Kobkrit Viriyayudhakorn
 

En vedette (20)

Docker Workshop for beginner
Docker Workshop for beginnerDocker Workshop for beginner
Docker Workshop for beginner
 
Beyond OpenStack
Beyond OpenStackBeyond OpenStack
Beyond OpenStack
 
How to contribute to OpenStack
How to contribute to OpenStackHow to contribute to OpenStack
How to contribute to OpenStack
 
OpenStack Ansible for private cloud at Kaidee
OpenStack Ansible for private cloud at KaideeOpenStack Ansible for private cloud at Kaidee
OpenStack Ansible for private cloud at Kaidee
 
Build cloud like Rackspace with OpenStack Ansible
Build cloud like Rackspace with OpenStack AnsibleBuild cloud like Rackspace with OpenStack Ansible
Build cloud like Rackspace with OpenStack Ansible
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
สร้างซอฟต์แวร์อย่างไรให้โดนใจผู้คน (How to make software that people love)
 
Efficient kernel backporting
Efficient kernel backportingEfficient kernel backporting
Efficient kernel backporting
 
Advanced network services insertions framework
Advanced network services insertions frameworkAdvanced network services insertions framework
Advanced network services insertions framework
 
How to write a Neutron plugin (stadium edition)
How to write a Neutron plugin (stadium edition)How to write a Neutron plugin (stadium edition)
How to write a Neutron plugin (stadium edition)
 
Grizzly summit: Quantum API
Grizzly summit: Quantum APIGrizzly summit: Quantum API
Grizzly summit: Quantum API
 
It's Not the Technology, It's You
It's Not the Technology, It's YouIt's Not the Technology, It's You
It's Not the Technology, It's You
 
Can you trust Neutron?
Can you trust Neutron?Can you trust Neutron?
Can you trust Neutron?
 
Quantum Grizzly Upgrade Paths
Quantum Grizzly Upgrade PathsQuantum Grizzly Upgrade Paths
Quantum Grizzly Upgrade Paths
 
KASan in a Bare-Metal Hypervisor
 KASan in a Bare-Metal Hypervisor  KASan in a Bare-Metal Hypervisor
KASan in a Bare-Metal Hypervisor
 
Tales From The Ship: Navigating the OpenStack Community Seas
Tales From The Ship: Navigating the OpenStack Community SeasTales From The Ship: Navigating the OpenStack Community Seas
Tales From The Ship: Navigating the OpenStack Community Seas
 
Containers for the Enterprise: It's Not That Simple
Containers for the Enterprise: It's Not That SimpleContainers for the Enterprise: It's Not That Simple
Containers for the Enterprise: It's Not That Simple
 
SDN Symposium - Cybera
SDN Symposium - CyberaSDN Symposium - Cybera
SDN Symposium - Cybera
 
CNCF and Fujitsu
CNCF and FujitsuCNCF and Fujitsu
CNCF and Fujitsu
 
Introduction to Openstack Network
Introduction to Openstack NetworkIntroduction to Openstack Network
Introduction to Openstack Network
 

Similaire à Docker Workshop Birthday #3

Similaire à Docker Workshop Birthday #3 (20)

Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Automated Snap Package build processes without the Build Service
Automated Snap Package build processes without the Build ServiceAutomated Snap Package build processes without the Build Service
Automated Snap Package build processes without the Build Service
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker for local development
Docker for local developmentDocker for local development
Docker for local development
 
Docker for Deep Learning (Andrea Panizza)
Docker for Deep Learning (Andrea Panizza)Docker for Deep Learning (Andrea Panizza)
Docker for Deep Learning (Andrea Panizza)
 
Improve your Java Environment with Docker
Improve your Java Environment with DockerImprove your Java Environment with Docker
Improve your Java Environment with Docker
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
DockerCon 2016 Seattle Recap
DockerCon 2016 Seattle RecapDockerCon 2016 Seattle Recap
DockerCon 2016 Seattle Recap
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
 
Developing apps in Windows Containers using Docker
Developing apps in Windows Containers using DockerDeveloping apps in Windows Containers using Docker
Developing apps in Windows Containers using Docker
 
Introduction to Docker for NodeJs developers at Node DC 2/26/2014
Introduction to Docker for NodeJs developers at Node DC 2/26/2014Introduction to Docker for NodeJs developers at Node DC 2/26/2014
Introduction to Docker for NodeJs developers at Node DC 2/26/2014
 
Bgoug 2019.11 building free, open-source, plsql products in cloud
Bgoug 2019.11   building free, open-source, plsql products in cloudBgoug 2019.11   building free, open-source, plsql products in cloud
Bgoug 2019.11 building free, open-source, plsql products in cloud
 
Docker 101 - Getting started
Docker 101 - Getting startedDocker 101 - Getting started
Docker 101 - Getting started
 
DevAssistant, Docker and You
DevAssistant, Docker and YouDevAssistant, Docker and You
DevAssistant, Docker and You
 
Super powered Drupal development with docker
Super powered Drupal development with dockerSuper powered Drupal development with docker
Super powered Drupal development with docker
 
Docker Continuous Delivery Workshop
Docker Continuous Delivery WorkshopDocker Continuous Delivery Workshop
Docker Continuous Delivery Workshop
 
Magento Docker Setup.pdf
Magento Docker Setup.pdfMagento Docker Setup.pdf
Magento Docker Setup.pdf
 
Hack Rio/OS
Hack Rio/OSHack Rio/OS
Hack Rio/OS
 
Work shop - an introduction to the docker ecosystem
Work shop - an introduction to the docker ecosystemWork shop - an introduction to the docker ecosystem
Work shop - an introduction to the docker ecosystem
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Docker Workshop Birthday #3

  • 1. Workshop Jirayut Nimsaeng (Dear) Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand
  • 2. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand #whoami ● Jirayut Nimsaeng (Dear) ● The Builder at ● Interested in Cloud and Open Source Technology ● Agile Practitioner and ScrumMaster with DevOps Driven Development
  • 3. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Developer Problems Developer Local Test QA Production
  • 4. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand What Developer needs Production-like Quick Repeatable
  • 5. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker can solve this problem Developer Local Test QA Production
  • 6. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker can ● Deploy (almost) everything
  • 7. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker can ● Deploy (almost) everywhere Native On VMs
  • 8. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand What is Docker? ● Service Platform to help code, test and deploy applications ● Combine with – Lightweight container virtualization – Work flows – Tooling
  • 9. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker Containers as a Service Platform
  • 10. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Containers vs. VMs
  • 11. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker image ● Docker images are read-only templates ● Each image consists of series of layers ● Docker use union file system to combine layers into single image ● Every image starts from base image
  • 12. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker image layers http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
  • 13. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker container ● A container is defined as a "union view" of a stack of layers the top of which is a read-write layer. http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
  • 14. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Image vs Container Docker Image is a class Docker Container is a instance of class
  • 15. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Image vs Container http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
  • 16. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Running Container http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
  • 17. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Dockerfile ● Dockerfile is instructions to build Docker image – How to run commands – Add files or directories – Create environment variables – What process to run when launching container ● Result from building Dockerfile is Docker image
  • 18. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Sample Dockerfile FROM ubuntu:14.04 MAINTAINER Jirayut Nimsaeng <w [at] winginfotech.net> ADD build-files /build-files RUN apt-get update RUN apt-get install -y openssh-server vim tmux rsync byobu RUN mkdir /var/run/sshd RUN sed -i 's/required pam_loginuid.so/optional pam_loginuid.so/g' /etc/pam.d/sshd CMD /start.sh EXPOSE 22
  • 19. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker Registry ● Docker Registry is the store for Docker image ● Docker Hub is public Docker Registry like Github ● Using Docker client to push and pull Docker image from Docker Registry ● You can create your own Docker Registry with Docker Distribution
  • 20. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker Hub
  • 21. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker workflows Dockerfile For App A Host 1 (Dev/Build Server) Docker Engine ImageAppAImageAppA Docker Registry Host 2 (Container Server) 1.Build 2.Push 3.Pull 4.Run Docker Engine ImageAppA ContainerAppAProduction
  • 22. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker Installation ● Docker Toolbox for Mac and Windows – https://www.docker.com/toolbox – All-in-one Docker installation ● Docker Engine ● Docker Machine ● Docker Compose ● Docker Kitematic ● VirtualBox
  • 23. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker installation ● Ubuntu based – https://docs.docker.com/installation/ubuntulinux/ – Recommend Ubuntu 14.04 64-bit LTS or up – curl -sSL https://get.docker.com/ | sudo sh ● Redhat based – https://docs.docker.com/installation/centos/ – Recommend CentOS 7 – curl -sSL https://get.docker.com/ | sh
  • 24. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker architecture Host Docker Engine Web Server 80 xxxx Docker Containers Database Docker Client socket 3306
  • 25. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Boot2docker architecture Host Virtualbox VM Docker Engine Web Server boot2docker-vm 80 1024+ Docker Containers Database 2376 Host-only 80 80 3306 Docker Client
  • 26. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Know the tools (1) ● Docker Client / Engine Host Virtualbox VM Docker Engine Web Server boot2docker-vm 80 1024+ Docker Containers Database 2376 Host-only 80 80 3306 Docker Client
  • 27. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Know the tools (2) ● Docker Machine – Lets you create Docker hosts on your computer, on cloud providers, or inside your own data center – Automated these steps ● Create Docker host ● Install Docker ● Configure Docker client to talk with server – Manage Docker multiple Docker host
  • 28. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Know the tools (3) ● VirtualBox – Virtualization software to run Docker host for Mac and Windows – VM has been configured and managed by Docker Machine
  • 29. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Know the tools (4) ● Docker Kitematic – Simple application for managing Docker containers on Mac and Windows
  • 30. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Know the tools (5) ● Docker Compose – Tool for defining and running multi-container applications with Docker in a single file
  • 31. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker Image name ● Official Docker Image – ubuntu:latest – centos:centos7 ● User's Docker Image on Docker Hub – google/cadvisor:0.5.0 – dockerfile/mongodb ● Docker Image on Private Docker Registry – r.winginfotech.net/ubuntu:14.10 – r:5000/docker-registry
  • 32. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Run first Docker container ● docker images ● docker pull r.winginfotech.net/ubuntu ● docker images ● docker run r.winginfotech.net/ubuntu echo “Hello World” ● docker run -i -t r.winginfotech.net/ubuntu bash – whoami – hostname – cat /etc/*release* – exit
  • 33. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker basic operations ● docker pull [name[:tag]] – docker pull r.winginfotech.net/centos – docker pull ubuntu:latest ● docker run [-itd] [name[:tag]] [command] ● docker ps ● docker ps -a ● docker rm [name or cid] ● docker rm [part of cid] ● docker images ● docker rmi [name:tag or iid]
  • 34. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Image name and tag ● docker pull r.winginfotech.net/ubuntu ● docker images ● docker pull r.winginfotech.net/ubuntu:15.10 ● docker images ● docker pull r.winginfotech.net/ubuntu:14.04 ● docker images
  • 35. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Create your first image ● docker run -it r.winginfotech.net/ubuntu bash – vim – echo 'Acquire::http::Proxy "http://r.winginfotech.net:3142";' > /etc/apt/apt.conf.d/11proxy – apt-get update – apt-get install -y vim – touch vim-installed – ls – exit ● docker ps -a ● docker commit [cid] ubuntu-vim ● docker images ● docker run -it ubuntu-vim bash – ls
  • 36. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker commit ● Commit takes a container's top-level read-write layer and burns it into a read-only layer. ● This turns a container into an immutable image. http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html
  • 37. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Expose ports ● docker run -it -p 80:80 ubuntu-vim bash – apt-get install -y apache2 – service apache2 start – Go to browser: http://ipaddress – exit ● Commit your apache2 container as ubuntu-apache2 with tag 14.04 and latest ● Make sure that new images have apache2 ● Clear your stopped containers
  • 38. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Run as daemon & expose port option ● docker run ubuntu-apache2 ● docker run -d ubuntu-apache2 service apache2 start ● docker run -d ubuntu-apache2 apachectl -DFOREGROUND ● docker run -d -p 80:80 ubuntu-apache2 apachectl -DFOREGROUND ● docker run -d -p 8880:80 ubuntu-apache2 apachectl -DFOREGROUND ● docker run -d -p 80 ubuntu-apache2 apachectl -DFOREGROUND ● docker ps
  • 39. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker container operation ● docker ps ● docker stop [container id or name] ● docker start [container id or name] ● docker kill [container id or name] ● docker logs [container id or name] ● docker diff [container id or name] ● docker top [container id or name] ● docker inspect [container id or name]
  • 40. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Some useful command & parameter ● docker run --name my-nginx -d -p 80:80 r.winginfotech.net/nginx ● docker ps ● docker exec -it my-nginx /bin/bash
  • 41. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Linking Host Web Server 80 80 Docker Containers Database 3306 3306
  • 42. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Linking Host Web Server 80 80 Docker Containers Database Linking
  • 43. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Running Wordpress without linking ● docker run -d –-name wp_mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mypass r.winginfotech.net/mysql ● docker run -d –-name wp -p 80:80 -e WORDPRESS_DB_PASSWORD=mypass -e WORDPRESS_DB_HOST=your-ip-address:3306 r.winginfotech.net/wordpress
  • 44. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Running Wordpress with linking ● docker run -d –-name wp_mysql -e MYSQL_ROOT_PASSWORD=mypass r.winginfotech.net/mysql ● docker run -d –-name wp -p 80:80 -e WORDPRESS_DB_PASSWORD=mypass --link wp_mysql:mysql r.winginfotech.net/wordpress
  • 45. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Data in Container (1) ● Default https://kvaes.wordpress.com/2016/02/11/docker-storage-patterns-for-persistence/
  • 46. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Data in Container (2) ● Data Volume https://kvaes.wordpress.com/2016/02/11/docker-storage-patterns-for-persistence/
  • 47. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Data in Container (3) ● Data Only Container https://kvaes.wordpress.com/2016/02/11/docker-storage-patterns-for-persistence/
  • 48. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Data in Container (4) ● Host Mapped Volume https://kvaes.wordpress.com/2016/02/11/docker-storage-patterns-for-persistence/
  • 49. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Running Wordpress with volume ● docker run -d –-name wp_mysql -e MYSQL_ROOT_PASSWORD=mypass r.winginfotech.net/mysql ● docker run -d –-name wp -p 80:80 -e WORDPRESS_DB_PASSWORD=mypass --link wp_mysql:mysql --volumes $(pwd)/uploads:/var/www/html/wp-content/uploads r.winginfotech.net/wordpress
  • 50. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker Compose ● Create docker-compose.yml file wordpress: image: r.winginfotech.net/wordpress ports: - "80:80" links: - db:mysql db: image: r.winginfotech.net/mysql environment: MYSQL_ROOT_PASSWORD: mypass ● docker-compose up
  • 51. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Play with Docker Compose ● docker-compose up ● docker-compose start ● docker-compose ps ● docker-compose stop ● docker-compose up -d ● docker-compose rm ● docker-compose down
  • 52. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Simple Voting Application https://github.com/docker/docker-birthday-3/
  • 53. Jirayut Nimsaeng Docker Workshop for beginner March 20, 2016 @ Odd-e Thailand Docker build ● Docker build is iteratively runs multiple commands at once. http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html