gdg using docker to streamline development
TRANSCRIPT
© Mesan AS
Streamline Your Development
Process with Docker
Trond Marius Ø[email protected]
GDG DevFest 2014
© Mesan AS
Streamline with Docker
© Mesan AS
About me
• Trond Marius Øvstetun
• CTO in Mesan
• Developer, Architect, Tech-lead+++
• 10+ years of experience building applications
© Mesan AS
How we build systems
Modern challenges
© Mesan AS
© Mesan AS
Challenges
• One big lump of software
• Scales as one
• Deploys as one
• Updates as one
• Develops as one
© Mesan AS
Breaking the Monolith
© Mesan AS
© Mesan AS
© Mesan AS
A new set of challenges
• Interdependencies
• Implicit ones - keys shared across systems
© Mesan AS
From a developers perspective
• Dependencies change
• add more systems
• systems change
• different kinds of deps
• search/messaging/storage/caching…
• How do we deal with this?
• try to run deps locally?
• export/import data
• the “shared development environment”
• moar, moar environments
© Mesan AS
© Mesan AS
What is Docker?
“Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.”
• Deploying and shipping software consistently is too hard
• Dependencies, libraries, configuration
• Consistency across environments (local, test, QA, production)
• A new abstraction – introduce the Container
© Mesan AS
What is a container?
© Mesan AS
What is a container?
• Lightweight linux environment
• Hermetically sealed, deployable
• Isolation
• Portability
• Raising the level of abstraction
• VMs = Idealized hardware
• Container = Idealized OS (+hardware)
© Mesan AS
Demos
© Mesan AS
Basic examples
• Docker Hello World!
$ docker run hello-world
• Interactive running in a container (or two!)
$ docker run -it ubuntu bash
• Running basic nginx in a container
$ docker run -d nginx
© Mesan AS
Building a container manually
• Run commands in interactive mode
• Commit changes
• Takes time –boring, manual & error prone
• What about reproducability?
$ docker run -i -t ubuntu bash
root@171950c2cf9d:/# touch my.conf
root@171950c2cf9d:/# vi my.conf
root@171950c2cf9d:/# apt-get install my-package
Reading package lists... Done
Building dependency tree
Reading state information... Done
$ docker commit 171950c2cf9d ovstetun/my
© Mesan AS
Dockerfile
my
Dockerfile + env
$ docker build .
$ docker build -t mynginx .
© Mesan AS
Exposing ports as Services
• Expose ports from a containerin the Dockerfile
EXPOSE 3000
• Open ports on the server
$ docker run -p 4000:3000 mynginx
© Mesan AS
Linking containers
• Declare dependency and link
docker run --link 1bc1:mysql nginx
• Available as environment variables
MYSQL_PORT_3306_TCP_ADDR=xxx
MYSQL_PORT_3306_TCP_PORT=xxx
© Mesan AS
Sharing containers
• Docker Hub
• Official reusable images
• Your own!
$ docker push ovstetun/mynginx
© Mesan AS
Developing using Docker
Exemplifying a workflow and setup
© Mesan AS
Example system
© Mesan AS
Setting up your system for Docker
• Depend on Services, not Resources or computers
• Run the same, identical container everywhere
• Docker links to Services
• Automate changes
• Database refactorings
• Search index updates
• …
© Mesan AS
Setting up your system for Docker
• One process per container
• Reuse (your own) base images
• Repeatable builds – use Dockerfiles
• Automate everything
© Mesan AS
Workflow
© Mesan AS
Working with dependencies
• Do some work in Ingredients module
• Run dependencies in Docker
• search + database
$ docker run -p 3306:3306 --name some-mysql \\
-e MYSQL_ROOT_PASSWORD=pwd -d o/ftdb:2
$ docker run -p 9300:9300 --name elastic \\
-d o/ftelastic:2
© Mesan AS
• Automatic linkingand management
• Simple configuration
© Mesan AS
Demo
© Mesan AS
Deploying to the Cloud
© Mesan AS
© Mesan AS
Kubernetes
• Master & Minions
• Pods
• collection of containers, run as a unit
• ReplicationControllers
• controllable
• Services
• proxy layer and load balancing – “dynamic Docker links”
© Mesan AS
Kubernetes
© Mesan AS
The future?
• The future lies in containers
• continue to see more examples of use cases
• Docker is the leader today
• The momentum is gigantic
• google, Microsoft, RedHat, Rackspace +++
© Mesan AS
Q & A