SlideShare a Scribd company logo
Adventures in
docker-compose
with Node.js
Whoami
Giovanni Lela
CTO@LinkMe
cofounder@MeanMilan
@lambrojos
http://github.com/lambrojos
Things no developer/architect/CTO likes in during
development
● recognizing wrong choices when it is too late
● mantaining different development
environments
● targeting that VERY specific version
of something
● spending hours on configuring the
dev environment
Fighting back
● Create approximation of systems and
architectures
● Isolate yourself from the host
● Infrastructure as code
● Automate like there is no to tomorrow
Isolated work environments and teamwork
● If you are working on a backend application
front end people can avoid writing tons of
mocks or use a shared staging environment
● In case of error the application state can be
debugged easily
Vagrant
Vagrant made this approach popular by
virtualizing machines on real
hypervisors,
● Very accurate replicas
● Performance issues when running
complex architectures
● Provisioning looks intense
Docker
● You don’t have virtual machines
● The OS kernel is shared in virtualized
environment called containers.
● The virtualized processes are essentially native, do
not require the overhead of virtual machines and still
provide a high level of isolation from the host OS
Docker in a nutshell
Some docker terms
● Image: a readonly template for creating
containers - they are defined with simple files
called Dockerfiles
● Container: A Docker container is a runnable
instance of a Docker image
Some more docker terms
● Registry: a repository of docker images
● Volumes: (aka data volumes): folders that
bypass docker’s union filesystem. We can use
them to map folders from the host machine to
the container
Containers and layers
Example Dockerfile
A dockerfile is like a recipe to build an image
Each line corresponds to a new layer in the image.
FROM node:7
RUN npm install -g knex nodemon mocha istanbul node-gyp snyk jsdoc
WORKDIR /src
Docker CLI is semi hard
Docker CLI can have quite a lot of options
Setting up a serious multi container environment
can be very hard
docker run -d -v ~/nginxlogs:/var/log/nginx -p 5000:80 -i nginx --
entrypoint /bin/bash example/nginx
Enter docker compose
Compose is a tool for defining
and running multi-container
Docker applications.
Enter docker-compose
Docker compose helps by defining and
coordinating multiple containers.
With Compose, you define a multi-container
application in a .yml single file, then spin your
application up in a single command which does
everything that needs to be done to get it running.
Example (docker-compose.yml)
mysql:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: passwordsarecool
MYSQL_DATABASE: node
volumes:
- ./conf/mysql/conf.d:/etc/mysql/conf.d
ports:
- "3306"
web:
build: .
ports:
- "80"
- "443"
- "22"
volumes:
- ./:/src
links:
- mysql
Key points
● We are not provisioning a set of machines, we
are defining a set of services
● Then isolating them in containers
● And then choosing how they interact
Cool things
Services and middlewares are super easy to install: as they can be installed right
from the docker registry, the version we want, with the image
Basic configuration is achieved with env vars, advanced configuration by mapping
volumes
Approximating the production environment
● a good approximation of
the production
environment is the key for
true happiness
● integration tests can be run
on local machines for cheap
- spot architectural issues
very very early
Even more goodies
Continous integration is super easy to setup: at its
most basic form it can be reduced to something
like:
docker-compose run myservice npm
test
Testing in docker-compose
Allows you test against real services not mocks- all
tests can be integration tests.
No CI provider lock-in (as long docker compose is
supported)
Lightweight - you can spin up a lot services and
simulate complex architectures
Production?
Can be also used to setup a quick and dirty staging
environment.
Just use the -d flag
Docker swarm?
Issues and not so cool things
It’s all fun and games as long as you work on linux
● On mac and windows it used to run on a virtual
machine
● Now it’s better because it runs on hyper-V on
windows and xhyve on MAC (which is still a
virtualization)
Issues
On mac and windows installing and updating
docker has been more time consuming than
expected
The first docker-compose up run is always
quite painful
SSH keys
What if you need your ssh credentials inside your
container? I learned to hate:
● ssh passphrases
● windows permissions
Other nasty stuff
/r/n
docker updates
mac os filesystem case sensitieves
Code time

More Related Content

What's hot (20)

PDF
Docker Compose to Production with Docker Swarm
Mario IC
 
PDF
Docker 101 Workshop slides (JavaOne 2017)
Eric Smalling
 
PDF
Docker
SangtongPeesing
 
PDF
Build & Deploy Multi-Container Applications to AWS
Docker, Inc.
 
PPTX
Docker and stuff
Varun Sharma
 
PDF
ContainerDayVietnam2016: Django Development with Docker
Docker-Hanoi
 
PDF
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
Mike Goelzer
 
PPT
Docker and CloudStack
Sebastien Goasguen
 
PPTX
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
Docker, Inc.
 
PPTX
Docker Compose: Docker Configuration for the Real World
Will Hall
 
PDF
Docker compose
Felipe Ruhland
 
PDF
Docker Started
Victor S. Recio
 
PPTX
Architecting .NET Applications for Docker and Container Based Deployments
Ben Hall
 
PDF
Docker on Windows
Stefan Scherer
 
PDF
Docker Fundamentals
Mien Dinh
 
PPTX
Docker and Windows: The State of the Union
Elton Stoneman
 
PPTX
Introduction to docker
Frederik Mogensen
 
PDF
Docker for Developers - Part 2 by Borja Burgos and Fernando Mayo
Docker, Inc.
 
PDF
Docker for Devs - John Zaccone, IBM
Docker, Inc.
 
PPTX
Docker Security workshop slides
Docker, Inc.
 
Docker Compose to Production with Docker Swarm
Mario IC
 
Docker 101 Workshop slides (JavaOne 2017)
Eric Smalling
 
Build & Deploy Multi-Container Applications to AWS
Docker, Inc.
 
Docker and stuff
Varun Sharma
 
ContainerDayVietnam2016: Django Development with Docker
Docker-Hanoi
 
What's New in Docker 1.12 (June 20, 2016) by Mike Goelzer & Andrea Luzzardi
Mike Goelzer
 
Docker and CloudStack
Sebastien Goasguen
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
Docker, Inc.
 
Docker Compose: Docker Configuration for the Real World
Will Hall
 
Docker compose
Felipe Ruhland
 
Docker Started
Victor S. Recio
 
Architecting .NET Applications for Docker and Container Based Deployments
Ben Hall
 
Docker on Windows
Stefan Scherer
 
Docker Fundamentals
Mien Dinh
 
Docker and Windows: The State of the Union
Elton Stoneman
 
Introduction to docker
Frederik Mogensen
 
Docker for Developers - Part 2 by Borja Burgos and Fernando Mayo
Docker, Inc.
 
Docker for Devs - John Zaccone, IBM
Docker, Inc.
 
Docker Security workshop slides
Docker, Inc.
 

Similar to Adventures in docker compose (20)

PDF
Docker in everyday development
Justyna Ilczuk
 
PDF
Docker primer and tips
Samuel Chow
 
PDF
Docker workshop GDSC_CSSC
GDSC UofT Mississauga
 
PDF
Real-World Docker: 10 Things We've Learned
RightScale
 
PDF
DCSF 19 Building Your Development Pipeline
Docker, Inc.
 
PPTX
Run automated tests in Docker
Oleksandr Metelytsia
 
PDF
DCEU 18: Building Your Development Pipeline
Docker, Inc.
 
PDF
[@NaukriEngineering] Docker 101
Naukri.com
 
PPTX
Accelerate your development with Docker
Andrey Hristov
 
PDF
Accelerate your software development with Docker
Andrey Hristov
 
ODP
DevAssistant, Docker and You
BalaBit
 
PDF
ContainerDayVietnam2016: Dockerize a small business
Docker-Hanoi
 
PDF
До чого прикладати Docker в Android? - UA Mobile 2019
UA Mobile
 
PDF
Dockerized maven
Matthias Bertschy
 
PPTX
RootConf 2014 Bangalore: Automating the Dev Environment - Introduction to Do...
Thoughtworks
 
PPTX
Automating Dev Environment - Introduction to Docker and Chef
kamalikamj
 
PDF
Docker Up and Running for Web Developers
Amr Fawzy
 
PDF
Docker up and Running For Web Developers
BADR
 
ODP
Docker on Power Systems
Cesar Maciel
 
PDF
codemotion-docker-2014
Carlo Bonamico
 
Docker in everyday development
Justyna Ilczuk
 
Docker primer and tips
Samuel Chow
 
Docker workshop GDSC_CSSC
GDSC UofT Mississauga
 
Real-World Docker: 10 Things We've Learned
RightScale
 
DCSF 19 Building Your Development Pipeline
Docker, Inc.
 
Run automated tests in Docker
Oleksandr Metelytsia
 
DCEU 18: Building Your Development Pipeline
Docker, Inc.
 
[@NaukriEngineering] Docker 101
Naukri.com
 
Accelerate your development with Docker
Andrey Hristov
 
Accelerate your software development with Docker
Andrey Hristov
 
DevAssistant, Docker and You
BalaBit
 
ContainerDayVietnam2016: Dockerize a small business
Docker-Hanoi
 
До чого прикладати Docker в Android? - UA Mobile 2019
UA Mobile
 
Dockerized maven
Matthias Bertschy
 
RootConf 2014 Bangalore: Automating the Dev Environment - Introduction to Do...
Thoughtworks
 
Automating Dev Environment - Introduction to Docker and Chef
kamalikamj
 
Docker Up and Running for Web Developers
Amr Fawzy
 
Docker up and Running For Web Developers
BADR
 
Docker on Power Systems
Cesar Maciel
 
codemotion-docker-2014
Carlo Bonamico
 
Ad

More from LinkMe Srl (8)

PDF
Corso su ReactJS
LinkMe Srl
 
PDF
A React Journey
LinkMe Srl
 
PDF
Webdriver.io
LinkMe Srl
 
PDF
Angular Intermediate
LinkMe Srl
 
PDF
NodeJS
LinkMe Srl
 
PDF
Angular js quickstart
LinkMe Srl
 
PDF
M&M - MeanMilan @CodeMotionMilan
LinkMe Srl
 
PPTX
Presentazione Codemotion
LinkMe Srl
 
Corso su ReactJS
LinkMe Srl
 
A React Journey
LinkMe Srl
 
Webdriver.io
LinkMe Srl
 
Angular Intermediate
LinkMe Srl
 
NodeJS
LinkMe Srl
 
Angular js quickstart
LinkMe Srl
 
M&M - MeanMilan @CodeMotionMilan
LinkMe Srl
 
Presentazione Codemotion
LinkMe Srl
 
Ad

Recently uploaded (20)

PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Digital Circuits, important subject in CS
contactparinay1
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 

Adventures in docker compose

  • 3. Things no developer/architect/CTO likes in during development ● recognizing wrong choices when it is too late ● mantaining different development environments ● targeting that VERY specific version of something ● spending hours on configuring the dev environment
  • 4. Fighting back ● Create approximation of systems and architectures ● Isolate yourself from the host ● Infrastructure as code ● Automate like there is no to tomorrow
  • 5. Isolated work environments and teamwork ● If you are working on a backend application front end people can avoid writing tons of mocks or use a shared staging environment ● In case of error the application state can be debugged easily
  • 6. Vagrant Vagrant made this approach popular by virtualizing machines on real hypervisors, ● Very accurate replicas ● Performance issues when running complex architectures ● Provisioning looks intense
  • 7. Docker ● You don’t have virtual machines ● The OS kernel is shared in virtualized environment called containers. ● The virtualized processes are essentially native, do not require the overhead of virtual machines and still provide a high level of isolation from the host OS
  • 8. Docker in a nutshell
  • 9. Some docker terms ● Image: a readonly template for creating containers - they are defined with simple files called Dockerfiles ● Container: A Docker container is a runnable instance of a Docker image
  • 10. Some more docker terms ● Registry: a repository of docker images ● Volumes: (aka data volumes): folders that bypass docker’s union filesystem. We can use them to map folders from the host machine to the container
  • 12. Example Dockerfile A dockerfile is like a recipe to build an image Each line corresponds to a new layer in the image. FROM node:7 RUN npm install -g knex nodemon mocha istanbul node-gyp snyk jsdoc WORKDIR /src
  • 13. Docker CLI is semi hard Docker CLI can have quite a lot of options Setting up a serious multi container environment can be very hard docker run -d -v ~/nginxlogs:/var/log/nginx -p 5000:80 -i nginx -- entrypoint /bin/bash example/nginx
  • 14. Enter docker compose Compose is a tool for defining and running multi-container Docker applications.
  • 15. Enter docker-compose Docker compose helps by defining and coordinating multiple containers. With Compose, you define a multi-container application in a .yml single file, then spin your application up in a single command which does everything that needs to be done to get it running.
  • 16. Example (docker-compose.yml) mysql: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: passwordsarecool MYSQL_DATABASE: node volumes: - ./conf/mysql/conf.d:/etc/mysql/conf.d ports: - "3306" web: build: . ports: - "80" - "443" - "22" volumes: - ./:/src links: - mysql
  • 17. Key points ● We are not provisioning a set of machines, we are defining a set of services ● Then isolating them in containers ● And then choosing how they interact
  • 18. Cool things Services and middlewares are super easy to install: as they can be installed right from the docker registry, the version we want, with the image Basic configuration is achieved with env vars, advanced configuration by mapping volumes
  • 19. Approximating the production environment ● a good approximation of the production environment is the key for true happiness ● integration tests can be run on local machines for cheap - spot architectural issues very very early
  • 20. Even more goodies Continous integration is super easy to setup: at its most basic form it can be reduced to something like: docker-compose run myservice npm test
  • 21. Testing in docker-compose Allows you test against real services not mocks- all tests can be integration tests. No CI provider lock-in (as long docker compose is supported) Lightweight - you can spin up a lot services and simulate complex architectures
  • 22. Production? Can be also used to setup a quick and dirty staging environment. Just use the -d flag Docker swarm?
  • 23. Issues and not so cool things It’s all fun and games as long as you work on linux ● On mac and windows it used to run on a virtual machine ● Now it’s better because it runs on hyper-V on windows and xhyve on MAC (which is still a virtualization)
  • 24. Issues On mac and windows installing and updating docker has been more time consuming than expected The first docker-compose up run is always quite painful
  • 25. SSH keys What if you need your ssh credentials inside your container? I learned to hate: ● ssh passphrases ● windows permissions
  • 26. Other nasty stuff /r/n docker updates mac os filesystem case sensitieves