containers #101 : docker onbuild triggers and introduction to docker compose
TRANSCRIPT
About the meetup • A series of 30 min webinars + 10 min
Q&A• Hands On• Session are recorded• Suggested topics and presenters are
welcome
Recording available athttps://vimeo.com/channels/containers101
About me • Developer, entrepreneur and
technology enthusiast• Live in the Silicon Valley since
2008 • Founder and CEO of Codefresh• Member of the Node.js foundation
@RazielTabib
About codefresh• A Docker platform for
development teams.• Build, Run & Test Docker
containers• New Innovator sponsor of
DockerCon Europe• We are hiring! email us to
[email protected]@codefresh
TerminologyDocker FileA recipe for Docker image Docker ImagesBlueprints of our applicationDocker ContainerCreated from docker images and are real instances of our applicationDocker DaemonBuilding, running and distributing Docker containersDocker ClientRun on our local machine and connect to the daemonDocker HubA registry of docker images
https://www.airpair.com/node.js/posts/getting-started-with-docker-for-the-nodejs-dev
Previous meetups
• Meetup #2: docker file, docker cache• Meetup #1: docker search, run & commit, docker hub
Recording available athttps://vimeo.com/channels/containers101
What we will see today
ubuntu
Node.js
ONBUILD
Base image
• Create base Docker image using Docker file w ONBUILD
What we will see today
• Build a simple micro-service• Create base Docker image using Docker file w ONBUILD
• Create new image with our micro-service
FROM base-image
….
Dockerfile
micro-service
micro-service
• Intro to docker compose
ubuntu
Node.js
ONBUILD
Base image
Docker file ONBUILD command The ONBUILD instruction adds to the image a trigger instruction to be executed at a later time, when the image is used as the base for another build. The trigger will be executed in the context of the downstream build, as if it had been inserted immediately after the FROM instruction in the downstream Dockerfile.
https://docs.docker.com/reference/builder/#onbuild
FROM base-image
Dockerfile
micro-service
FROM ubuntu:latestMAINTAINER [email protected]
ONBUILD COPY ./package.json src/ONBUILD RUN npm installONBUILD COPY . src/……..
Dockerfile
Docker file ONBUILD command
ubuntu
Node.js
ONBUILD
base-image
COPY ./package.json src/RUN npm installCOPY . src/
Web: build: . ports: - “9000:9000” links: - mongo
mongo: image: mongo:latest ports: - “27017:27017”
docker-compose.yml
Docker compose
Web (nodejs) Mongo
https://github.com/Codefresh-Examples/express-angular-mongo
What we saw today
• Build a simple micro-service
ubuntu
Node.js
ONBUILD
micro-service image
• Create base Docker image using Docker file w ONBUILD
• Create new image with our micro-service
FROM base-image
….
Dockerfile
micro-service
micro-service
• Intro to docker compose
additional resources• Codefresh blog blog.codefresh.io• Containers #101 http://www.meetup.com/Containers-101-online-meetup/• Docker Online meetup (delivered by Docker) http://www.meetup.com/Docker-Online-Meetup/
@codefresh