Tdd Apps

# Miami Scala Meetup Presentation Notes

Dec 14, 2016 2 minute read

These are my notes of my Docker Presentation. Held at the Microsoft Innovation Center on December 14th, 2016.

Example 1

uname -a
docker run ubuntu uname -a

Example 2

ls /
docker run ubuntu ls /

Example 3: Long lived Containers

docker run -p 8080:80 seqvence/static-site

docker ps

Open localhost:8080

Example 4: Environment Variables

docker run -e AUTHOR="Miami" -p 8080:80 seqvence/static-site

Open localhost:8080

Example 5: Multiple Containers

docker run -e AUTHOR="Miami" -p 8081:80 seqvence/static-site
docker run -e AUTHOR="Downtown" -p 8082:80 seqvence/static-site

Open Site 1
Open Site 2

Example 6: Docker Compose

nano docker-compose.yaml
site1:
    image: seqvence/static-site
    environment:
        - AUTHOR=Miami
    ports:
        - 8081:80

site2:
    image: seqvence/static-site
    environment:
        - AUTHOR=Downtown
    ports:
        - 8082:80
docker-compose up

Open Site 1
Open Site 2

Cleanup docker-compose down

Example 7: Dockerfile

nano app.js
    var express = require('express')
    var app = express()

    app.get('/', function (req, res) {
      res.send('Hello World!')
    })

    app.listen(3000, function () {
      console.log('Example app listening on port 3000!')
    })
npm i express --save 
node app.js

Sample Express Site

nano Dockerfile
FROM node

RUN mkdir -p /usr/src/app

COPY app.js /usr/src/app/

RUN npm i express --save

CMD ["node", "/usr/src/app/app.js"]
docker build -t camilin87/docker-intro-node .
docker run -p 8080:3000 camilin87/docker-intro-node

Open Node Site

Example 8: Publish an Image

docker push camilin87/docker-intro-node

View Our published Image

Run it yourself docker run -p 8080:3000 camilin87/docker-intro-node

Cleanup

docker rm -f $(docker ps -a -q)

Never miss a post. Subscribe to our newsletter