introducing docker

18
Introduction to Docker by Bill Wang email: [email protected]

Upload: bill-wang

Post on 16-Aug-2015

56 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: Introducing docker

Introduction to Docker

by Bill Wangemail: [email protected]

Page 2: Introducing docker

Agenda

● About myself● What is docker● Install Docker● Demo #1 - Hello-world● Demo #2 - Docker-2048● Best practice with Docker● Demo #3 - Jira in containter● Basic commands● Useful for start-up business

Page 3: Introducing docker

Bill Wang

● Used to be system administrator● Worked in bank, telecomm, government,

cutting-edge companies● Automation Specialist ● Scriping● Start-up with a small business ● Learn Docker since 2014

Page 4: Introducing docker

What is docker?

● Content agnostic● Hardware agnostic● Content isolation and interaction● Automation● Highly efficient● Separation of duties● Build once, run anywhere

Page 5: Introducing docker

Install Docker

● Linux● Mac OS● Windows● Installation https://docs.docker.

com/installation/

Page 6: Introducing docker

Using docker with CoreOS

● Docker build-in ● Pre-configured with popular tools for running

Linux containers.● Boot extremely fast● Can be used in production environment

Page 7: Introducing docker

Install CoreOS in Vagrant

● git clone https://github.com/coreos/coreos-vagrant.git

● vagrant status● vagrant up● vagrant ssh● docker info

Page 8: Introducing docker

Demo #1 - Hello-world

● docker run --rm hello-world● docker image● docker ps -a

Page 9: Introducing docker

Demo #2 - Docker-2048

● docker run -d -p 8080:80 alexwhen/docker-2048

● Access the game http://172.17.8.101:8080/● docker history alexwhen/docker-2048● docker ps -a● docker inspect alexwhen/docker-2048● docker build -t 2048 .

Page 10: Introducing docker

Demo #2 - Build your own image

https://github.com/alexwhen/docker-2048/blob/master/DockerfileFROM alpine:latestMAINTAINER alex <[email protected]>RUN apk --update add nginxCOPY 2048 /usr/share/nginx/htmlEXPOSE 80CMD ["nginx", "-g", "daemon off;"]

Page 11: Introducing docker

Best practice with Docker

● All services in one container - WRONG● mysql, php, apache, java in each container.● Not too complex in one Dockerfile● One container provides one service● Best to limit in 3 layers - base (ubuntu, centos, java, etc)- middleware (php, node.js, mysql, etc)- own data

Page 12: Introducing docker

Demo #3 - Jira in Containers - plan

● Jira (java + database)● looking for exist docker images https://registry.hub.docker.com/u/blacklabelops/jira/

● PostgreSQL container● Jira container ● Link the database container to jira container● Troubleshooting will be easier.

Page 13: Introducing docker

Dome #3 - database container - postgresql

● docker run --name postgresql -d \ -e 'PSQL_TRUST_LOCALNET=true' \ -e 'DB_USER=jiradb' \ -e 'DB_PASS=jellyfish' \ -e 'DB_NAME=jiradb' \ -p 5432:5432 \ sameersbn/postgresql:9.4-1

Page 14: Introducing docker

Demo #3 - jira container● docker run -d --name jira \

-e "DATABASE_URL=postgresql://jiradb@postgresql/jiradb" \ -e "DB_PASSWORD=jellyfish" \ --link postgresql:postgresql \ -p 8100:8080 blacklabelops/jira

● Access jira via http://172.17.8.101:8100/

Page 15: Introducing docker

Basic commands● Dockerfile● docker image● docker build● docker ps -a● docker run● docker start/stop● docker inspect

Page 16: Introducing docker

Useful for start-up business

● simple and easy● save time and initial investment● efficient and automation● focus on coding and business, not the IT

environment setup● big support from Cloud companies, famous

IT companies and open source community

Page 17: Introducing docker

Question

Page 18: Introducing docker

Reference

● https://www.docker.com/● http://training.docker.com/● https://www.vagrantup.com/● http://boot2docker.io/