Skip to content

Latest commit

 

History

History
119 lines (77 loc) · 1.62 KB

cheat-sheet.MD

File metadata and controls

119 lines (77 loc) · 1.62 KB

cheat-sheet

git clone https://github.com/triforkse/meetup.git && cd meetup

app0

Dockerfile

FROM ubuntu

RUN apt-get update -y && apt-get install -y nginx

ADD ./src /usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]

OR

# this image is much smaller than the ubuntu one
FROM fnichol/uhttpd

ADD ./src /www

Commands

# to build our image
docker build -t app0 .

# to start a container from our image
docker run -d -p 3000:80 app0

On Linux, visit localhost:3000 in your browser. Mac/Windows visit the IP:3000 seen when running docker-machine ip default

app1

Dockerfile

FROM node:5.0
MAINTAINER Max Malm <[email protected]>

ENV NODE_ENV=production

ADD . /app
WORKDIR /app

RUN npm install

CMD ["npm", "start"]

app2

Dockerfile

FROM mhart/alpine-node

ENV NODE_ENV=production

ADD . /app
WORKDIR /app

RUN npm install && npm run build

CMD ["npm", "start"]

Commands

# run a mongodb container named db
docker run --name db -d mongo

# build the app2 image
docker build -t app2 .

# run a container based on app2 with a link to db
docker run -p 3001:3000 --link db -d app2

On Linux, visit localhost:3001 in your browser. Mac/Windows visit the IP:3001 seen when running docker-machine ip default

docker-compose.yml

web:
  build: .
  ports:
    - "3001:3000"
  links:
    - db
db:
  image: mongo
  container_name: db

Read more about Docker Compose https://docs.docker.com/compose/

Commands

# to build (or start from cache) and run our machines
docker-machine up -d

# to build without cache
docker-machine build --no-cache