SlideShare a Scribd company logo
learning:
with Thomas @ Search Investment Group
Slides & codes: http://bit.ly/thomasdocker
Ref: 8 surprising facts about real docker adoption
Ref: Docker Customers, StackShare
Virtual Machines Docker
Benefits
● Lightweight
● Experiment and use whatever technology fits best
● Having multiple versions of tools without crashing
(Java, Python 2 & 3, etc)
● Automated deployment
● Quickly and accurately set up environments for DEV, UAT, etc.
● Scale easily
Today’s Demo
● Install Docker
● Download and run a Hello World Docker image
● Compose our own Hello World Docker Image
● Compose our own Docker Image that contains a PHP-MySQL
application
Install Docker (MacOS)
https://www.docker.com/products/
Install Docker (Windows)
Hello World
Hello-world container
Docker Store
Find the Image
Hello World
$ docker --version
Docker version 1.13.0, build 49bf474
$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
$ docker run hello-world
Hello from Docker!
(...)
Ref for our “SSL Deep Inspection”:
Docker behind proxy that changes
ssl certificate
Basic Docker Commands
$ docker images
(list the images you pulled)
$ docker ps
(list the running containers)
$ docker ps -a
(list all containers, including exited)
$ docker [command] --help
(check the documentation)
$ docker rmi [image ID]
(remove the image by the associated ID
- you don’t have to type in full ID!)
$ docker stop [container ID]
(stop the running container by the ID)
$ docker rm [container ID]
(stop and remove the container from the
ps -a list)
$ docker ps -aq | xargs docker rm
(stop and remove all containers)
Build our own Hello World
Python container
Our hello-world container
Hello World in Python
$ echo 'print("Hello from Thomas")' > app.py
$ cat app.py
print("Hello from Thomas")
$ python app.py
Hello from Thomas
Docker Store
Dockerfile & docker-compose.yml
$ vi Dockerfile
FROM python
MAINTAINER Thomas Tong <hello@thomastong.me>
COPY app.py app.py
CMD python app.py
$ vi docker-compose.yml
helloworld:
build: .
Describes the necessary
steps to build the container
Describes the container in
its running state
(environment variables,
dependencies to others
containers, etc)
Ref: Docker Compose vs. Dockerfile
Compose a Docker Image
$ ls
Dockerfile app.py
docker-compose.yml
$ docker-compose build
Building helloworld
Step 1/4 : FROM python
latest: Pulling from library/python
5040bd298390: Pull complete
fce5728aad85: Pull complete
76610ec20bf5: Pull complete
52f3db4b5710: Pull complete
45b2a7e03e44: Pull complete
75ef15b2048b: Pull complete
e41da2f0bac3: Pull complete
Digest:
sha256:cba517218b4342514e000557e6e9100018f980cda866420
ff61bfa9628ced1dc
Status: Downloaded newer image for python:latest
---> 775dae9b960e
Step 2/4 : MAINTAINER Thomas Tong
<hello@thomastong.me>
---> Running in b257c26e3b5e
---> b6a9ca588053
Removing intermediate container b257c26e3b5e
Step 3/4 : COPY app.py app.py
---> c30eb29c8920
Removing intermediate container 5c74e320839d
Step 4/4 : CMD python app.py
---> Running in 5c2295d819ad
---> b54de6654b62
Removing intermediate container 5c2295d819ad
Successfully built b54de6654b62
Run the Docker Image
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
2helloworld_helloworld latest b54de6654b62 7 minutes ago 687 MB
python latest 775dae9b960e 7 minutes ago 687 MB
$ docker run [image name/ID]
Hello from Thomas
$ docker-compose up
Creating 2helloworld_helloworld_1
Attaching to 2helloworld_helloworld_1
helloworld_1 | Hello from Thomas
2helloworld_helloworld_1 exited with code 0
You can only use this after
building the image
Build and start according
to the Dockerfile and
docker-compose.yml, good
for development
Apache httpd + PHP + MySQL
PHP httpd
Our site
MySQL
Sample App - Feed Moby Dock
Credits: Originally done in Flask by acloud.guru, rewritten in PHP
Feed button and fed count
Random message
from database
Docker Store
Docker Store
Docker Store
“latest” tag is used by default
Our Files
$ ls -R
Dockerfile docker-compose.yml
./cert:
server.crt server.csr server.key
./conf:
000-default.conf apache2.conf default-ssl.conf php.ini
./database:
seed.sql
./public:
(...)
Docker image config files
HTTPS Cert
Apache and PHP
config files
SQL to create DB
Our Web App files
Dockerfile
FROM php:apache
RUN docker-php-ext-install mysqli
COPY conf/php.ini /usr/local/etc/php/
RUN a2enmod headers
RUN a2enmod rewrite
RUN a2enmod ssl
COPY cert/server.crt /etc/ssl/certs/
COPY cert/server.key /etc/ssl/certs/
COPY conf/000-default.conf /etc/apache2/sites-enabled/
COPY conf/default-ssl.conf /etc/apache2/sites-enabled/
COPY conf/apache2.conf /etc/apache2/
COPY public/ /var/www/html/
COPY .env /var/www/html/
Found in Docker Store PHP image’s description
Run apache commands to set up additional modules
Copy php.ini from image to container’s file system
Ref: Docker Command CMD vs RUN, COPY vs ADD
Copy SSL cert and httpd config files
Copy Web App files
docker-compose.yml
example_app_db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- '3306:3306'
volumes:
- ~/.docker-volumes/exampleapp/mysql/data:/var/lib/mysql
- ./database/seed.sql:/docker-entrypoint-initdb.d/seed.sql
example_app:
build: .
links:
- example_app_db
ports:
- '80:80'
- '443:443'
Variables found in MySQL image descriptionUse MySQL image
Link with MySQL image defined above
Map HTTP and HTTPS ports (local port:container port)
Map local volume to
container volume
and seed SQL file to
init directory
Read .env file with ${VAR_NAME}
Map local port 3306 to container
Build and Run
$ vi .env
MYSQL_ROOT_PASSWORD=password
MYSQL_DATABASE=exampleapp
MYSQL_USER=exampleapp
MYSQL_PASSWORD=password
$ docker-compose up
(...)
$ docker ps
CONTAINER ID IMAGE PORTS
bda700bcf1ab 3phpapp_example_app 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp
cf443ee159e7 mysql 0.0.0.0:3306->3306/tcp
Setting up environments with different configs,
you may:
● create multiple docker-compose.yml files
● create multiple .env files and use reference
Check port
mappings here
Docker Inspect
$ docker inspect [container ID]
(...)
"Env": [
"MYSQL_ROOT_PASSWORD=password",
"MYSQL_PASSWORD=password",
"MYSQL_USER=exampleapp",
"MYSQL_DATABASE=exampleapp",
(...)
$ docker exec -it [container ID] sh
#
Check whether environment
variables are loaded correctly
Run bash shell in a container
to check its file system
Check Seed Database
# mysql -u root -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| exampleapp |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.02 sec)
mysql> use exampleapp
mysql> show tables;
+----------------------+
| Tables_in_exampleapp |
+----------------------+
| Feed |
| Messages |
+----------------------+
2 rows in set (0.00 sec)
mysql> select * from Messages;
+----------------------------------------------+
| message |
+----------------------------------------------+
| Thanks good sir. I am feeling quite healthy! |
| Thanks for the meal buddy. |
| Please stop feeding me. I am getting huge! |
+----------------------------------------------+
3 rows in set (0.00 sec)
Try it in https://localhost/
Click the button and hear
from Moby Dock
If you want to redo
this exercise, don’t
forget to remove
database files from
your local machine
(hint: check the yml)
What have we Achieved?
● Learnt the skills
○ To download and use Docker images
○ To compose our own Docker image
● Learnt the benefits
○ Lightweight
○ Experiment and use whatever technology fits best
○ Having multiple versions of tools without crashing (Java, Python 2 & 3, etc)
○ Automated deployment
○ Quickly and accurately set up environments for development, UAT, etc.
○ Scale easily
Scale easily? Really?
...or Actually the Same?
● What to do when adding new machines?
● How do containers discover each other?
● What happens if containers die?
● What if the host machine is down?
● What happens if 1 container is using excessive resources?
#GIFEE
● GIFEE - Google Infrastructure for Everyone Else
● Google starts over 2 billion containers per week
● Container Orchestration
● Docker Swarm, Kubernetes
● Cluster as a giant computer
Modern DevOps Architecture
Git Push Git Hook
Git / Source Ctrl. Jenkins / Continuous Integration Server
Static Tests
Unit Tests
Reporting
Docker Compose
Build
Docker Orchestration Docker Registry
Store
Docker Pull
...and they lived happily ever after.
Further Watchings & Readings
● Docker for DevOps - From Development to Production
MOOC by acloud.guru
● Scalable Microservices with Kubernetes
MOOC by Google and Udacity
● Shipping code with Docker + Kubernetes (Cantonese)
Recordings of 20 Jun 2016 Meetup @ OneSky
● ...and remember not to overkill: It’s the Future, It really is the future
Blog by CircleCI
learning:
with Thomas @ Search Investment Group
Slides & codes: http://bit.ly/thomasdocker

More Related Content

What's hot

Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Alan Forbes
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Google Developer Group Zürich
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
Christophe Muller
 
Understand how docker works
Understand how docker worksUnderstand how docker works
Understand how docker works
Justin Li
 
Introduction to Containers and Docker
Introduction to Containers and DockerIntroduction to Containers and Docker
Introduction to Containers and Docker
Rob Loach
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
dotCloud
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
Jeffrey Ellin
 
Basic docker for developer
Basic docker for developerBasic docker for developer
Basic docker for developer
Weerayut Hongsa
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
psconnolly
 
Docker and containers - For Boston Docker Meetup Workshop in March 2015
Docker and containers - For Boston Docker Meetup Workshop in March 2015Docker and containers - For Boston Docker Meetup Workshop in March 2015
Docker and containers - For Boston Docker Meetup Workshop in March 2015
Jonas Rosland
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
Dr. Syed Hassan Amin
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
Hao Fan
 
Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9 Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9
Jérôme Petazzoni
 
Docker - introduction
Docker - introductionDocker - introduction
Docker - introduction
Michał Kurzeja
 
Docker and containers : Disrupting the virtual machine(VM)
Docker and containers : Disrupting the virtual machine(VM)Docker and containers : Disrupting the virtual machine(VM)
Docker and containers : Disrupting the virtual machine(VM)
Rama Krishna B
 
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQIntroduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
dotCloud
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
Sparkbit
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
Instruqt
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
Jérôme Petazzoni
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
Phuc Nguyen
 

What's hot (20)

Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Understand how docker works
Understand how docker worksUnderstand how docker works
Understand how docker works
 
Introduction to Containers and Docker
Introduction to Containers and DockerIntroduction to Containers and Docker
Introduction to Containers and Docker
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Basic docker for developer
Basic docker for developerBasic docker for developer
Basic docker for developer
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
 
Docker and containers - For Boston Docker Meetup Workshop in March 2015
Docker and containers - For Boston Docker Meetup Workshop in March 2015Docker and containers - For Boston Docker Meetup Workshop in March 2015
Docker and containers - For Boston Docker Meetup Workshop in March 2015
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9 Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9
 
Docker - introduction
Docker - introductionDocker - introduction
Docker - introduction
 
Docker and containers : Disrupting the virtual machine(VM)
Docker and containers : Disrupting the virtual machine(VM)Docker and containers : Disrupting the virtual machine(VM)
Docker and containers : Disrupting the virtual machine(VM)
 
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQIntroduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 

Viewers also liked

Docker, From zero to hero
Docker, From zero to heroDocker, From zero to hero
Docker, From zero to hero
Maurice De Beijer [MVP]
 
Easy applications deployment on OpenStack clouds
Easy applications deployment on OpenStack cloudsEasy applications deployment on OpenStack clouds
Easy applications deployment on OpenStack clouds
Giovanni Toraldo
 
From zero to Docker
From zero to DockerFrom zero to Docker
From zero to Docker
Giovanni Toraldo
 
Dockers zero to hero - (medium version)
Dockers zero to hero - (medium version)Dockers zero to hero - (medium version)
Dockers zero to hero - (medium version)
Nicolas De Loof
 
Docker zero
Docker zeroDocker zero
Docker: from zero to nonzero
Docker: from zero to nonzeroDocker: from zero to nonzero
Docker: from zero to nonzero
Francesco Lo Franco
 
Rabbit mq messaginginthecloud_v_mworld_2010_ms
Rabbit mq messaginginthecloud_v_mworld_2010_msRabbit mq messaginginthecloud_v_mworld_2010_ms
Rabbit mq messaginginthecloud_v_mworld_2010_ms
Rabbit MQ
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Chris Chen
 
From Zero to Hero - Nexinto
From Zero to Hero - NexintoFrom Zero to Hero - Nexinto
From Zero to Hero - Nexinto
Johann Paulus Almeida
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Aditya Konarde
 
Docker 101 - from 0 to Docker in 30 minutes
Docker 101 - from 0 to Docker in 30 minutesDocker 101 - from 0 to Docker in 30 minutes
Docker 101 - from 0 to Docker in 30 minutes
Luciano Fiandesio
 
Introduction To Docker
Introduction To DockerIntroduction To Docker
Introduction To Docker
Hamilton Turner
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
Peng Xiao
 
From zero to hero with Docker
From zero to hero with DockerFrom zero to hero with Docker
From zero to hero with Docker
Maurice De Beijer [MVP]
 
The DevOps Hero Toolkit: Nexus, Jenkins and Docker
The DevOps Hero Toolkit: Nexus, Jenkins and DockerThe DevOps Hero Toolkit: Nexus, Jenkins and Docker
The DevOps Hero Toolkit: Nexus, Jenkins and Docker
SeniorStoryteller
 
Zero downtime-java-deployments-with-docker-and-kubernetes
Zero downtime-java-deployments-with-docker-and-kubernetesZero downtime-java-deployments-with-docker-and-kubernetes
Zero downtime-java-deployments-with-docker-and-kubernetes
Arjan Schaaf
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
Robert Reiz
 
NetflixOSS and ZeroToDocker Talk
NetflixOSS and ZeroToDocker TalkNetflixOSS and ZeroToDocker Talk
NetflixOSS and ZeroToDocker Talk
aspyker
 
Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment
Arun prasath
 
29.05.2009, NEWSWIRE, Issue 71
29.05.2009, NEWSWIRE, Issue 7129.05.2009, NEWSWIRE, Issue 71
29.05.2009, NEWSWIRE, Issue 71
The Business Council of Mongolia
 

Viewers also liked (20)

Docker, From zero to hero
Docker, From zero to heroDocker, From zero to hero
Docker, From zero to hero
 
Easy applications deployment on OpenStack clouds
Easy applications deployment on OpenStack cloudsEasy applications deployment on OpenStack clouds
Easy applications deployment on OpenStack clouds
 
From zero to Docker
From zero to DockerFrom zero to Docker
From zero to Docker
 
Dockers zero to hero - (medium version)
Dockers zero to hero - (medium version)Dockers zero to hero - (medium version)
Dockers zero to hero - (medium version)
 
Docker zero
Docker zeroDocker zero
Docker zero
 
Docker: from zero to nonzero
Docker: from zero to nonzeroDocker: from zero to nonzero
Docker: from zero to nonzero
 
Rabbit mq messaginginthecloud_v_mworld_2010_ms
Rabbit mq messaginginthecloud_v_mworld_2010_msRabbit mq messaginginthecloud_v_mworld_2010_ms
Rabbit mq messaginginthecloud_v_mworld_2010_ms
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
From Zero to Hero - Nexinto
From Zero to Hero - NexintoFrom Zero to Hero - Nexinto
From Zero to Hero - Nexinto
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Docker 101 - from 0 to Docker in 30 minutes
Docker 101 - from 0 to Docker in 30 minutesDocker 101 - from 0 to Docker in 30 minutes
Docker 101 - from 0 to Docker in 30 minutes
 
Introduction To Docker
Introduction To DockerIntroduction To Docker
Introduction To Docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
From zero to hero with Docker
From zero to hero with DockerFrom zero to hero with Docker
From zero to hero with Docker
 
The DevOps Hero Toolkit: Nexus, Jenkins and Docker
The DevOps Hero Toolkit: Nexus, Jenkins and DockerThe DevOps Hero Toolkit: Nexus, Jenkins and Docker
The DevOps Hero Toolkit: Nexus, Jenkins and Docker
 
Zero downtime-java-deployments-with-docker-and-kubernetes
Zero downtime-java-deployments-with-docker-and-kubernetesZero downtime-java-deployments-with-docker-and-kubernetes
Zero downtime-java-deployments-with-docker-and-kubernetes
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
NetflixOSS and ZeroToDocker Talk
NetflixOSS and ZeroToDocker TalkNetflixOSS and ZeroToDocker Talk
NetflixOSS and ZeroToDocker Talk
 
Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment
 
29.05.2009, NEWSWIRE, Issue 71
29.05.2009, NEWSWIRE, Issue 7129.05.2009, NEWSWIRE, Issue 71
29.05.2009, NEWSWIRE, Issue 71
 

Similar to Learning Docker with Thomas

Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
Vincent De Smet
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
Justyna Ilczuk
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
Patrick Mizer
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
OKLABS
 
Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
Binary Studio
 
Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
nigamsajal14
 
docker.pdf
docker.pdfdocker.pdf
docker.pdf
EishaTirRaazia1
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
Guido Schmutz
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
皓鈞 張
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
Philip Zheng
 
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
Ambassador Labs
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
CloudHero
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
Alper Kanat
 
Présentation de Docker
Présentation de DockerPrésentation de Docker
Présentation de Docker
Proto204
 
Containers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech TalkContainers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech Talk
Red Hat Developers
 
Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2
Binary Studio
 
How to _docker
How to _dockerHow to _docker
How to _docker
Abdur Rab Marjan
 
Docking with Docker
Docking with DockerDocking with Docker
Docker @ Atlogys
Docker @ AtlogysDocker @ Atlogys
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
Giacomo Bagnoli
 

Similar to Learning Docker with Thomas (20)

Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
 
Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
 
Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
 
docker.pdf
docker.pdfdocker.pdf
docker.pdf
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇時代在變 Docker 要會:台北 Docker 一日入門篇
時代在變 Docker 要會:台北 Docker 一日入門篇
 
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Présentation de Docker
Présentation de DockerPrésentation de Docker
Présentation de Docker
 
Containers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech TalkContainers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech Talk
 
Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2
 
How to _docker
How to _dockerHow to _docker
How to _docker
 
Docking with Docker
Docking with DockerDocking with Docker
Docking with Docker
 
Docker @ Atlogys
Docker @ AtlogysDocker @ Atlogys
Docker @ Atlogys
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 

Recently uploaded

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 

Recently uploaded (20)

GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 

Learning Docker with Thomas

  • 1. learning: with Thomas @ Search Investment Group Slides & codes: http://bit.ly/thomasdocker
  • 2. Ref: 8 surprising facts about real docker adoption
  • 5. Benefits ● Lightweight ● Experiment and use whatever technology fits best ● Having multiple versions of tools without crashing (Java, Python 2 & 3, etc) ● Automated deployment ● Quickly and accurately set up environments for DEV, UAT, etc. ● Scale easily
  • 6. Today’s Demo ● Install Docker ● Download and run a Hello World Docker image ● Compose our own Hello World Docker Image ● Compose our own Docker Image that contains a PHP-MySQL application
  • 12. Hello World $ docker --version Docker version 1.13.0, build 49bf474 $ docker pull hello-world Using default tag: latest latest: Pulling from library/hello-world 78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 $ docker run hello-world Hello from Docker! (...) Ref for our “SSL Deep Inspection”: Docker behind proxy that changes ssl certificate
  • 13. Basic Docker Commands $ docker images (list the images you pulled) $ docker ps (list the running containers) $ docker ps -a (list all containers, including exited) $ docker [command] --help (check the documentation) $ docker rmi [image ID] (remove the image by the associated ID - you don’t have to type in full ID!) $ docker stop [container ID] (stop the running container by the ID) $ docker rm [container ID] (stop and remove the container from the ps -a list) $ docker ps -aq | xargs docker rm (stop and remove all containers)
  • 14. Build our own Hello World Python container Our hello-world container
  • 15. Hello World in Python $ echo 'print("Hello from Thomas")' > app.py $ cat app.py print("Hello from Thomas") $ python app.py Hello from Thomas
  • 17. Dockerfile & docker-compose.yml $ vi Dockerfile FROM python MAINTAINER Thomas Tong <hello@thomastong.me> COPY app.py app.py CMD python app.py $ vi docker-compose.yml helloworld: build: . Describes the necessary steps to build the container Describes the container in its running state (environment variables, dependencies to others containers, etc) Ref: Docker Compose vs. Dockerfile
  • 18. Compose a Docker Image $ ls Dockerfile app.py docker-compose.yml $ docker-compose build Building helloworld Step 1/4 : FROM python latest: Pulling from library/python 5040bd298390: Pull complete fce5728aad85: Pull complete 76610ec20bf5: Pull complete 52f3db4b5710: Pull complete 45b2a7e03e44: Pull complete 75ef15b2048b: Pull complete e41da2f0bac3: Pull complete Digest: sha256:cba517218b4342514e000557e6e9100018f980cda866420 ff61bfa9628ced1dc Status: Downloaded newer image for python:latest ---> 775dae9b960e Step 2/4 : MAINTAINER Thomas Tong <hello@thomastong.me> ---> Running in b257c26e3b5e ---> b6a9ca588053 Removing intermediate container b257c26e3b5e Step 3/4 : COPY app.py app.py ---> c30eb29c8920 Removing intermediate container 5c74e320839d Step 4/4 : CMD python app.py ---> Running in 5c2295d819ad ---> b54de6654b62 Removing intermediate container 5c2295d819ad Successfully built b54de6654b62
  • 19. Run the Docker Image $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE 2helloworld_helloworld latest b54de6654b62 7 minutes ago 687 MB python latest 775dae9b960e 7 minutes ago 687 MB $ docker run [image name/ID] Hello from Thomas $ docker-compose up Creating 2helloworld_helloworld_1 Attaching to 2helloworld_helloworld_1 helloworld_1 | Hello from Thomas 2helloworld_helloworld_1 exited with code 0 You can only use this after building the image Build and start according to the Dockerfile and docker-compose.yml, good for development
  • 20. Apache httpd + PHP + MySQL PHP httpd Our site MySQL
  • 21. Sample App - Feed Moby Dock Credits: Originally done in Flask by acloud.guru, rewritten in PHP Feed button and fed count Random message from database
  • 24. Docker Store “latest” tag is used by default
  • 25. Our Files $ ls -R Dockerfile docker-compose.yml ./cert: server.crt server.csr server.key ./conf: 000-default.conf apache2.conf default-ssl.conf php.ini ./database: seed.sql ./public: (...) Docker image config files HTTPS Cert Apache and PHP config files SQL to create DB Our Web App files
  • 26. Dockerfile FROM php:apache RUN docker-php-ext-install mysqli COPY conf/php.ini /usr/local/etc/php/ RUN a2enmod headers RUN a2enmod rewrite RUN a2enmod ssl COPY cert/server.crt /etc/ssl/certs/ COPY cert/server.key /etc/ssl/certs/ COPY conf/000-default.conf /etc/apache2/sites-enabled/ COPY conf/default-ssl.conf /etc/apache2/sites-enabled/ COPY conf/apache2.conf /etc/apache2/ COPY public/ /var/www/html/ COPY .env /var/www/html/ Found in Docker Store PHP image’s description Run apache commands to set up additional modules Copy php.ini from image to container’s file system Ref: Docker Command CMD vs RUN, COPY vs ADD Copy SSL cert and httpd config files Copy Web App files
  • 27. docker-compose.yml example_app_db: image: mysql environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} ports: - '3306:3306' volumes: - ~/.docker-volumes/exampleapp/mysql/data:/var/lib/mysql - ./database/seed.sql:/docker-entrypoint-initdb.d/seed.sql example_app: build: . links: - example_app_db ports: - '80:80' - '443:443' Variables found in MySQL image descriptionUse MySQL image Link with MySQL image defined above Map HTTP and HTTPS ports (local port:container port) Map local volume to container volume and seed SQL file to init directory Read .env file with ${VAR_NAME} Map local port 3306 to container
  • 28. Build and Run $ vi .env MYSQL_ROOT_PASSWORD=password MYSQL_DATABASE=exampleapp MYSQL_USER=exampleapp MYSQL_PASSWORD=password $ docker-compose up (...) $ docker ps CONTAINER ID IMAGE PORTS bda700bcf1ab 3phpapp_example_app 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp cf443ee159e7 mysql 0.0.0.0:3306->3306/tcp Setting up environments with different configs, you may: ● create multiple docker-compose.yml files ● create multiple .env files and use reference Check port mappings here
  • 29. Docker Inspect $ docker inspect [container ID] (...) "Env": [ "MYSQL_ROOT_PASSWORD=password", "MYSQL_PASSWORD=password", "MYSQL_USER=exampleapp", "MYSQL_DATABASE=exampleapp", (...) $ docker exec -it [container ID] sh # Check whether environment variables are loaded correctly Run bash shell in a container to check its file system
  • 30. Check Seed Database # mysql -u root -p mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | exampleapp | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.02 sec) mysql> use exampleapp mysql> show tables; +----------------------+ | Tables_in_exampleapp | +----------------------+ | Feed | | Messages | +----------------------+ 2 rows in set (0.00 sec) mysql> select * from Messages; +----------------------------------------------+ | message | +----------------------------------------------+ | Thanks good sir. I am feeling quite healthy! | | Thanks for the meal buddy. | | Please stop feeding me. I am getting huge! | +----------------------------------------------+ 3 rows in set (0.00 sec)
  • 31. Try it in https://localhost/ Click the button and hear from Moby Dock If you want to redo this exercise, don’t forget to remove database files from your local machine (hint: check the yml)
  • 32. What have we Achieved? ● Learnt the skills ○ To download and use Docker images ○ To compose our own Docker image ● Learnt the benefits ○ Lightweight ○ Experiment and use whatever technology fits best ○ Having multiple versions of tools without crashing (Java, Python 2 & 3, etc) ○ Automated deployment ○ Quickly and accurately set up environments for development, UAT, etc. ○ Scale easily Scale easily? Really?
  • 33. ...or Actually the Same? ● What to do when adding new machines? ● How do containers discover each other? ● What happens if containers die? ● What if the host machine is down? ● What happens if 1 container is using excessive resources?
  • 34. #GIFEE ● GIFEE - Google Infrastructure for Everyone Else ● Google starts over 2 billion containers per week ● Container Orchestration ● Docker Swarm, Kubernetes ● Cluster as a giant computer
  • 35. Modern DevOps Architecture Git Push Git Hook Git / Source Ctrl. Jenkins / Continuous Integration Server Static Tests Unit Tests Reporting Docker Compose Build Docker Orchestration Docker Registry Store Docker Pull
  • 36. ...and they lived happily ever after.
  • 37. Further Watchings & Readings ● Docker for DevOps - From Development to Production MOOC by acloud.guru ● Scalable Microservices with Kubernetes MOOC by Google and Udacity ● Shipping code with Docker + Kubernetes (Cantonese) Recordings of 20 Jun 2016 Meetup @ OneSky ● ...and remember not to overkill: It’s the Future, It really is the future Blog by CircleCI
  • 38. learning: with Thomas @ Search Investment Group Slides & codes: http://bit.ly/thomasdocker