/docker-recipes

Docker Recipes

Primary LanguageShell

Docker Recipes

Setup

Docker Machine

curl -L https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_darwin-amd64 > /usr/local/bin/docker-machine
docker-machine create --driver virtualbox mydocker

Application Server

Single Application Server

docker run -it -p 8080:8080 jboss/wildfly

List exact version of layers being pulled

Save Container Running State

Multiple Instances of an Application Server

  1. Create multiple machine

  2. One application server on each machine

Load Balancing

  1. Create a new machine for LB

Undertow

Apache

Persistence

This section will explain how an Application Server and a Database server can be used to deploy an application.

In-memory Database

docker run -it -p 8080:8080 arungupta/javaee7-hol

Same Host, Using Linking

docker run --name mysqldb -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL_ROOT_PASSWORD=supersecret -d mysql
docker run --name mywildfly --link mysqldb:db -p 8080:8080 -d arungupta/wildfly-mysql-javaee7
docker-machine ip

Same Host, Using Compose

curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose up -d
docker-compose ps
docker-compose logs
docker-machine ip
curl http://<IP_ADDRESS>:8080/employees/resources/employees/

Persistence on Data-only Containers

docker create --name mysql_data -v /var/lib/mysql mysql
docker run --name mysqldb --volumes-from mysql_data -v /var/lib/mysql:/var/lib/mysql -e MYSQL_USER=mysql -e MYSQL_PASSWORD=mysql -e MYSQL_DATABASE=sample -e MYSQL_ROOT_PASSWORD=supersecret -it -p 3306:3306 mysql

Clustering

What are the different clustering frameworks? Where do they excel? Can they work with each other? Do they need to work with each other? Pros/cons of each framework?

Framework Pros Cons

Swarm

Kubernetes

Mesos

Juju

Docker Swarm

docker run swarm create
docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://$TOKEN swarm-master
eval $(docker-machine env swarm-master)
docker info
docker-machine create -d virtualbox --swarm --swarm-discovery token://$TOKEN swarm-node-01
docker-machine create -d virtualbox --swarm --swarm-discovery token://$TOKEN swarm-node-02
docker-machine ls
docker info
docker ps
eval $(docker-machine env --swarm swarm-master)
docker run -it -p 8080:8080 arungupta/javaee7-hol
docker ps

Deploy Java EE application to Docker Swarm

Mesos

TBD

Juju

TBD

Application Development Tooling

IDE Pros Cons

Eclipse

NetBeans

IntelliJ

What support is offered by the three major IDEs to enable application development on Docker?

NetBeans

No support yet

Testing

How do you test applications running using Docker?

Test Java EE Applications using Arquillian Cube

PaaS

What does it take to run Docker images on PaaS?

PaaS Pros Cons

OpenShift

Amazon

Google

Amazon

Google

Full Stack

This section will explain how different components of a typical Java EE application can be setup using Docker.

Messaging

Caching

Transactions

Mail