1 of 11

Using Docker For Frontend Development

2 of 11

What Is Docker?

  • Tool for building and running containerized environments
  • What is a container? How is it different than a VM?
    • An OS running on top of your existing host OS
    • Containers consume fewer resources than a VM
    • Use an isolated file system

3 of 11

Why use Docker In Development?

  • Ease of onboarding new team members
  • Consistency between members, and between dev and prod
  • Isolate dependencies from host environment
  • Declarative environment
  • More easily claim an error is not in your part of the stack
  • Collated logs from multiple processes

4 of 11

Is Docker Really For Frontend Devs?

  • Very frequently don’t have access to good test environments
    • Security reasons
    • Inaccurate or missing mock services
    • User contention
  • Problems can arise in frontend work due to environments
    • Differing versions of Node
    • OS effects

5 of 11

What do I need to know to get started?

6 of 11

How To Use Docker In Development?�Dockerfiles

  • Dockerfiles define an image for containers to be built from
  • Dockerfiles specify:
    • Base image including an OS and possibly an application
    • Actions applied to the base image, customizing the environment
    • Default behaviour of the container when ran

7 of 11

How To Use Docker In Development?�Dockerfile

Example Dockerfile:

FROM ubuntu:latest

LABEL author="nils@bitovi.com"

RUN apt-get update

RUN apt-get install -y python python-pip wget

RUN pip install Flask

ADD hello.py /home/hello.py

WORKDIR /home

8 of 11

How To Use Docker In Development?

docker-compose

  • docker-compose is a CLI that runs containers via runtime configurations
  • Configurations are specified in a docker-compose.yml file
  • Offers full declarative control over runtime:
    • which services are dependencies of a given service
    • what host folders to mount into the service (e.g source code)
    • amount of logs to keep for a given service
    • working directory and default command when run

9 of 11

How To Use Docker In Development?

docker-compose.yml

Example docker-compose.yml:

version: '3'

services:

db:

image: postgres

web:

build: .

command: python manage.py runserver 0.0.0.0:8000

depends_on:

- db

volumes:

- .:/code

ports:

- "8000:8000"

10 of 11

Additional Resources

11 of 11

Questions?