SlideShare a Scribd company logo
Node.js in a Docker Container
Lenworth Henry (lenworth.henry@gmail.com)
What is Docker
●

●

Docker is an easy way to create a lightweight
container from any application
The same container you use in development
can be scaled to production on any platform
that supports Linux Containers (Amazon, VMs,
etc)
What can you do with Docker
●

Software distribution (app + dependencies)
–

e.g. NodeJs web apps (app+node+mongo+redis)

●

Fast spin-up VMs (no booting)

●

Automated testing and continuous integration/deployment.

●

●

Deploying and scaling databases and back-end services
in a service-oriented environment.
Document what components you need to run your
application
Why did I seek out Docker
●

●

●

Every time a new framework or library was
added to our code base the developers got
out of sync and we lost productivity
We needed a way to synchronize our
development environments
I also needed a way to keep track of all the
components that we were using in our
application (i.e. not use history to tell what I
have installed)
Why not Vagrant
●

●

●

Vagrant requires each machine to have
VM software like Virtuabox
Vagrant is not designed for creating
containers for production because of
all the overhead
Vagrant wasn't any easier to configure
than docker, but, the container footprint
was larger
What  you will need
●

A workstation running Linux kernel 3.8
or greater
–

●

Docker containers can run inside VMs like
Virtuabox, but, as Linux containers they
are made for Linux

Knowledge of how to configure your
application on bare hardware
–

There is lots of help for this
Getting Started With Docker
Simple Docker Example
Docker speak
●

●

●

A container is a running instance of an
image.
You create an image starting with one of
the images found on the index and
adding any customizations either from
inside the running container or using a
Dockerfile
Dockerfile-->(build)-->Image---(run)->Container
Two work­flows with docker
●

Using commits
–
–

Connect to the shell of the base image and add whatever software,
customizations and your source (e.g. pull a git remote repository)

–

Commit to a new image

–
●

Run a base image

Run that image

Using Dockerfile
–

Create a dockerfile that includes all your configurations,
customizations and access to your source

–

This can all be pulled down from git to a different workstation

–

This is the most reliable option since your Dockerfile should be
rewritten that you can recreate the image with one command.
How to create a Docker File
●

If you don't remember all the packages
you installed then you can launch a
shell using a base image and then run
all the steps. Each step can be copied
to the docker file as a “RUN” command
Shell for Your Container
●

Once a docker image has been
created you can run it and enter the
bash shell using this command:
–

sudo docker run -t -i --rm ubuntu bash
Docker gotchas
●

You can only run one command or entrypoint for a container
–
–

●

●

You only have one cmd or entrypoint. Only one will get executed.
You must create a start script or use something like supervisord

If you change your source on the client you have to rebuild the image to see
those changes on the container.
You can't have long running processes in your Dockerfile
–

Each step is meant to execute and complete

–

Daemon like functionality should be executed when the container is running
Two containers
●

●

●

DB container is separate because it
rarely changes
The Node app resides in its own
container
Communication is enabled between
the two containers using linking
–

Linking works the same in production
environment
Example MEAN Stack app
●

MongoDB, Express, Angular and Node
–

Uses PassPortJS for authentication
Need to start multiple 
processes?
●

●

Each Dockerfile will have only one
entry point
Two options:
–

Create your own shell script that starts up
the processes and call that using a CMD
or ENTRYPOINT

–

Use supervisord
Example supervisord.conf
Helpful Docker commands 
●

logs (sudo docker logs @containerid)
–

●

Gives a print out of the tty after running

ps (sudo docker ps)
–
–

●

Shows you all running containers
Containers running in daemon mode will show
up here for as long as they are running

stop (sudo docker stop @containerid)
–

Stops a running container
Docker Tips
●

Only run in daemon mode (-d) if you have run
it without -d to see if there are any problems
with your configuration
–

●

You will not see errors printed out to stdout while
trying to load the container

Watch your disk space while creating images
and containers
–

Docker creates intermediate containers that can
quickly eat up disk space

–

Use the -rm=true when building
Questions and Helpful Links
●

●

●

●

Main Docker Site:
https://docs.docker.io/
Index Site (Prebuilt image search):
https://index.docker.io/

How to cleanup docker disk usage:
http://sosedoff.com/2013/12/17/cleanup-docker-cont

Docker Networking Details:
https://blog.codecentric.de/en/2014/01/docker-netwo

More Related Content

What's hot (20)

PDF
Docker introduction - Part 1
Alessandro Mignogna
 
PDF
Meetup 05 27-2015
Ranjan Parthasarathy
 
PPTX
Docker Compose: Docker Configuration for the Real World
Will Hall
 
PPTX
Introduction to Docker - Getting Started with Docker
Aiyana Shukla
 
ODP
Docker. Micro services for lazy developers
Eugene Krevenets
 
PDF
Sep Nasiri "Upwork PHP Architecture"
Fwdays
 
PPTX
Building CLI Applications with Golang
Anshul Patel
 
PPTX
Academy PRO: Docker. Part 4
Binary Studio
 
PDF
Introduction to Docker Container
Samsul Ma'arif
 
PDF
Boston Code Dojo - Docker meetup slides
Calvin Froedge
 
PPTX
docker compose
Alex Fernandez
 
PDF
Moving to Docker... Finally!
Squareboat
 
PDF
Docker 101
Hung-Che Lo
 
PDF
Rkt Container Engine
Thuc Le Dong
 
PDF
Docker for developers
Anvay Patil
 
PDF
Docker cheat-sheet
Peđa Delić
 
PPTX
Academy PRO: Docker. Part 2
Binary Studio
 
PPTX
Academy PRO: Docker. Part 1
Binary Studio
 
PPTX
Introduction to docker
removed_b0e2342824f6227286f54ba461ebc0fe
 
PDF
Orchestration of docker containers at scale
Yeshwanth Kumar
 
Docker introduction - Part 1
Alessandro Mignogna
 
Meetup 05 27-2015
Ranjan Parthasarathy
 
Docker Compose: Docker Configuration for the Real World
Will Hall
 
Introduction to Docker - Getting Started with Docker
Aiyana Shukla
 
Docker. Micro services for lazy developers
Eugene Krevenets
 
Sep Nasiri "Upwork PHP Architecture"
Fwdays
 
Building CLI Applications with Golang
Anshul Patel
 
Academy PRO: Docker. Part 4
Binary Studio
 
Introduction to Docker Container
Samsul Ma'arif
 
Boston Code Dojo - Docker meetup slides
Calvin Froedge
 
docker compose
Alex Fernandez
 
Moving to Docker... Finally!
Squareboat
 
Docker 101
Hung-Che Lo
 
Rkt Container Engine
Thuc Le Dong
 
Docker for developers
Anvay Patil
 
Docker cheat-sheet
Peđa Delić
 
Academy PRO: Docker. Part 2
Binary Studio
 
Academy PRO: Docker. Part 1
Binary Studio
 
Orchestration of docker containers at scale
Yeshwanth Kumar
 

Similar to Introduction to Docker for NodeJs developers at Node DC 2/26/2014 (20)

PDF
[@NaukriEngineering] Docker 101
Naukri.com
 
PDF
Dockerized maven
Matthias Bertschy
 
PDF
Docker primer and tips
Samuel Chow
 
PDF
Docker in everyday development
Justyna Ilczuk
 
PDF
Using Docker to build and test in your laptop and Jenkins
Micael Gallego
 
PDF
Docker workshop GDSC_CSSC
GDSC UofT Mississauga
 
PPTX
Run automated tests in Docker
Oleksandr Metelytsia
 
PDF
Docker Up and Running for Web Developers
Amr Fawzy
 
PDF
Docker up and Running For Web Developers
BADR
 
PDF
Introduction to Docker and Monitoring with InfluxData
InfluxData
 
PDF
docker.pdf
EishaTirRaazia1
 
PDF
Lecture eight to be introduced in class.
nigamsajal14
 
PDF
JOSA TechTalks - Docker in Production
Jordan Open Source Association
 
PPTX
Docker for .NET Developers
Taswar Bhatti
 
PDF
Introduction of Docker and Docker Compose
Dr. Ketan Parmar
 
PDF
Docker for developers
DrupalDay
 
PDF
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ElasTest Project
 
PDF
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
Puppet
 
PPTX
Настройка окружения для кросскомпиляции проектов на основе docker'a
corehard_by
 
PPTX
Powercoders · Docker · Fall 2021.pptx
IgnacioTamayo2
 
[@NaukriEngineering] Docker 101
Naukri.com
 
Dockerized maven
Matthias Bertschy
 
Docker primer and tips
Samuel Chow
 
Docker in everyday development
Justyna Ilczuk
 
Using Docker to build and test in your laptop and Jenkins
Micael Gallego
 
Docker workshop GDSC_CSSC
GDSC UofT Mississauga
 
Run automated tests in Docker
Oleksandr Metelytsia
 
Docker Up and Running for Web Developers
Amr Fawzy
 
Docker up and Running For Web Developers
BADR
 
Introduction to Docker and Monitoring with InfluxData
InfluxData
 
docker.pdf
EishaTirRaazia1
 
Lecture eight to be introduced in class.
nigamsajal14
 
JOSA TechTalks - Docker in Production
Jordan Open Source Association
 
Docker for .NET Developers
Taswar Bhatti
 
Introduction of Docker and Docker Compose
Dr. Ketan Parmar
 
Docker for developers
DrupalDay
 
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ElasTest Project
 
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
Puppet
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
corehard_by
 
Powercoders · Docker · Fall 2021.pptx
IgnacioTamayo2
 
Ad

Recently uploaded (20)

PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Ad

Introduction to Docker for NodeJs developers at Node DC 2/26/2014

  • 1. Node.js in a Docker Container Lenworth Henry ([email protected])
  • 2. What is Docker ● ● Docker is an easy way to create a lightweight container from any application The same container you use in development can be scaled to production on any platform that supports Linux Containers (Amazon, VMs, etc)
  • 3. What can you do with Docker ● Software distribution (app + dependencies) – e.g. NodeJs web apps (app+node+mongo+redis) ● Fast spin-up VMs (no booting) ● Automated testing and continuous integration/deployment. ● ● Deploying and scaling databases and back-end services in a service-oriented environment. Document what components you need to run your application
  • 4. Why did I seek out Docker ● ● ● Every time a new framework or library was added to our code base the developers got out of sync and we lost productivity We needed a way to synchronize our development environments I also needed a way to keep track of all the components that we were using in our application (i.e. not use history to tell what I have installed)
  • 5. Why not Vagrant ● ● ● Vagrant requires each machine to have VM software like Virtuabox Vagrant is not designed for creating containers for production because of all the overhead Vagrant wasn't any easier to configure than docker, but, the container footprint was larger
  • 6. What  you will need ● A workstation running Linux kernel 3.8 or greater – ● Docker containers can run inside VMs like Virtuabox, but, as Linux containers they are made for Linux Knowledge of how to configure your application on bare hardware – There is lots of help for this
  • 9. Docker speak ● ● ● A container is a running instance of an image. You create an image starting with one of the images found on the index and adding any customizations either from inside the running container or using a Dockerfile Dockerfile-->(build)-->Image---(run)->Container
  • 10. Two work­flows with docker ● Using commits – – Connect to the shell of the base image and add whatever software, customizations and your source (e.g. pull a git remote repository) – Commit to a new image – ● Run a base image Run that image Using Dockerfile – Create a dockerfile that includes all your configurations, customizations and access to your source – This can all be pulled down from git to a different workstation – This is the most reliable option since your Dockerfile should be rewritten that you can recreate the image with one command.
  • 11. How to create a Docker File ● If you don't remember all the packages you installed then you can launch a shell using a base image and then run all the steps. Each step can be copied to the docker file as a “RUN” command
  • 12. Shell for Your Container ● Once a docker image has been created you can run it and enter the bash shell using this command: – sudo docker run -t -i --rm ubuntu bash
  • 13. Docker gotchas ● You can only run one command or entrypoint for a container – – ● ● You only have one cmd or entrypoint. Only one will get executed. You must create a start script or use something like supervisord If you change your source on the client you have to rebuild the image to see those changes on the container. You can't have long running processes in your Dockerfile – Each step is meant to execute and complete – Daemon like functionality should be executed when the container is running
  • 14. Two containers ● ● ● DB container is separate because it rarely changes The Node app resides in its own container Communication is enabled between the two containers using linking – Linking works the same in production environment
  • 15. Example MEAN Stack app ● MongoDB, Express, Angular and Node – Uses PassPortJS for authentication
  • 16. Need to start multiple  processes? ● ● Each Dockerfile will have only one entry point Two options: – Create your own shell script that starts up the processes and call that using a CMD or ENTRYPOINT – Use supervisord
  • 18. Helpful Docker commands  ● logs (sudo docker logs @containerid) – ● Gives a print out of the tty after running ps (sudo docker ps) – – ● Shows you all running containers Containers running in daemon mode will show up here for as long as they are running stop (sudo docker stop @containerid) – Stops a running container
  • 19. Docker Tips ● Only run in daemon mode (-d) if you have run it without -d to see if there are any problems with your configuration – ● You will not see errors printed out to stdout while trying to load the container Watch your disk space while creating images and containers – Docker creates intermediate containers that can quickly eat up disk space – Use the -rm=true when building
  • 20. Questions and Helpful Links ● ● ● ● Main Docker Site: https://docs.docker.io/ Index Site (Prebuilt image search): https://index.docker.io/ How to cleanup docker disk usage: http://sosedoff.com/2013/12/17/cleanup-docker-cont Docker Networking Details: https://blog.codecentric.de/en/2014/01/docker-netwo