Docker at Auckland Node.js Meetup

#docker

Download Cheatsheet

Docker Cheatsheet

Slides

You can download the pdf at Speakerdeck.com: Docker for developers.

Files used

Dockerfile:

from ubuntu

run apt-get update && \
  apt-get install -y wget xz-utils && \
  wget "https://nodejs.org/dist/v8.11.2/node-v8.11.2-linux-x64.tar.xz" && \
  tar xf node-v8.11.2-linux-x64.tar.xz -C /opt && \
  ln -s /opt/node-v8.11.2-linux-x64/bin/npm /usr/local/bin/npm && \
  ln -s /opt/node-v8.11.2-linux-x64/bin/node /usr/local/bin/node && \
  apt-get install -y postgresql-client && \
  rm /node-v8.11.2-linux-x64.tar.xz && \
  rm -rf /var/lib/apt/lists/*

docker-compose.yml:

version: "3.3"

services:
  app:
    build:
      context: .
    volumes:
      - .:/app
      - node_modules:/app/node_modules
    working_dir: /app
    links:
      - db

  db:
    image: postgres

volumes:
  node_modules:

Commands

Using only docker:

$ docker run --rm hello-world
$ docker build -t mynode .
$ docker run --rm -it mynode bash
$ docker run --rm -it -v /home/dmitry/myproject:/app mynode bash
$ docker run --rm -it -v /home/dmitry/myproject:/app -w /app mynode bash
$ docker run --rm -it -v /home/dmitry/myproject:/app -w /app -v node_modules:/app/node_modules mynode bash

Using docker-compose:

$ docker-compose pull
$ docker-compose build
$ docker-composer run --rm web bash
$ docker-composer run --rm web bash -c "psql -h db -U postgres"

Thanks for coming :)