Dockerizing your apps

Building Docker Images

app

image

containers

registry

Approaches

Imperative

Declarative

VM Like

Dockerfile

(manual)

(automated)

Imperative

registry

image

image

intermediate container

code

cp

build

commit

pull

run

push

  1. pull image
  2. run container 
  3. copy source code 
  4. build/compile
  5. commit
  6. push

Steps

dockerfile
FROM
RUN
COPY
EXPOSE
CMD
dockerfile
FROM
RUN
COPY
EXPOSE
CMD
docker build

image

http://hub.docker.com

http://store.docker.com

sign up

Building Image for Worker App

vote ui
redis
worker
db
results
  • Java App
  • Maven

https://github.com/schoolofdevops/voting-app-worker

registry

centos

install jdk

install mvn

mvn compile

mvn

mvn compile

Worker app

https://gist.github.com/initcron/f35f7854a8176374a48963ed8aae0b8e

Application Code

Image creation instructions (Manual)

https://github.com/schoolofdevops/voting-app-worker

registry

mvn

mvn

intermediate container

code

cp

build

commit

pull

run

artifact

host

Build Stage

registry

java

java

intermediate container

artifact

cp

commit

pull

run

push

host

package Stage

user/app:v2

Dockerfile

Dockerfile


FROM microsoft/dotnet-samples:aspnetapp

WORKDIR /app

RUN mkdir C:\site

ENTRYPOINT ["cmd"]

build

docker image build -t <dockrhub user id>/app:v2 .

docker image ls 

dot (current directory)

test image

docker container run -idt --name workertest2 <dockrhub user id>/app:v2 

docker container ls 

docker logs workertest2




docker image tag  <dockrhub user id>/app:v2  <dockrhub user id>/app:latest

docker image ls 
docker image push <dockrhub user id>/app:latest

docker image push <dockrhub user id>/app

Tag

publish

push

docker image push <dockrhub user id>/app:latest

docker image push <dockrhub user id>/app
Made with Slides.com