Skip to content

NOTE20180329

Somkiat Puisungnoen edited this page Jul 26, 2019 · 1 revision

Note of Day 1

  • Why docker ?
    • Software development changes
    • Container vs. VM
    • Container vs. Process
  • Docker
    • Build => Image
    • Ship => Registry
    • Run => Container
  • Hello world with Docker
    • docker image
    • docker container

Java Workshop

Hello.java

public class Hello {
	public static void main(String[] args) {
		System.out.println("Hello Docker from Java");
	}
}

How to run ?

$docker container run --rm  -v $(pwd):/test -w /test openjdk:10-jdk-slim javac Hello.java
$docker container run --rm  -v $(pwd):/test -w /test openjdk:10-jdk-slim java Hello
  • Write Dockerfile
  • Build image from Dockerfile

Note of Day 2

  • Basic of Networking
  • Basic of Volume
  • Workshop with Java Web application (Apache Maven + Apache Tomcat + Mysql)

Step 1.1 Build WAR file with Apache Maven

$docker image pull maven:3.5.3-jdk-8-alpine
$docker container run --rm -w /src -v $(pwd):/src maven:3.5.3-jdk-8-alpine mvn clean package

Step 1.2 Build WAR file with Apache Maven with Container Volume

// Create container volume with busybox to keep all dependencies/libraries
$docker container run --name m2 -v /root/.m2 busybox

// Create container to build WAR file
$docker container run --rm -w /src -v $(pwd):/src --volumes-from m2 maven:3.5.3-jdk-8-alpine mvn clean package

Step 1.3 Build WAR file with Dockerfile

$docker image build -t maven_build -f Dockerfile_build .
$docker container run --rm -v $(pwd)/m2:/root/.m2  maven_build:latest
  • Working with MySQL + Initial data
  • Working with Docker compose
  • Working with Docker swarm
  • Working with Registry