Last active
August 29, 2015 14:01
-
-
Save jwelshiv/52318509cc6e2a454dc7 to your computer and use it in GitHub Desktop.
docker osx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DOCKER-VERSION 0.3.4 | |
FROM ubuntu:latest | |
RUN apt-get -y update && apt-get -y upgrade | |
RUN apt-get -y install python-software-properties python g++ make software-properties-common | |
RUN add-apt-repository ppa:chris-lea/node.js && apt-get update | |
RUN apt-get -y install git nodejs | |
# Bundle app source | |
ADD ./src /src | |
# Install app dependencies | |
RUN cd /src; npm install | |
EXPOSE 8080 | |
CMD ["node", "/src/index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "docker-node", | |
"private": true, | |
"version": "0.0.1", | |
"description": "Node.js app using docker", | |
"author": "jwelshiv", | |
"dependencies": { | |
"express": "3.2.4" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Download latest VirtualBox | |
### https://www.virtualbox.org/wiki/Downloads | |
brew update | |
brew install docker boot2docker | |
### Port forwarding | |
for i in {49000..49900}; do | |
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i"; | |
VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i"; | |
done | |
boot2docker init | |
boot2docker up | |
### Quick check | |
docker pull busybox | |
docker run busybox /bin/echo hello world | |
### Node example | |
### In new directory with -- | |
### Dockerfile | |
### src/ | |
### src/index.js | |
docker build -t <username>/docker-node . | |
docker run -p 49160:8080 -d <username>/docker-node | |
curl -i localhost:49160 | |
### See logs | |
### (for latest running container) | |
docker logs $(docker ps -l -q) | |
### See all running containers | |
docker ps | |
### See all images | |
docker images | |
### Push to public repo | |
### https://index.docker.io | |
docker push <username>/docker-node | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
// Constants | |
var PORT = 8080; | |
// App | |
var app = express(); | |
app.get('/', function (req, res) { | |
res.send('Hello World\n'); | |
}); | |
app.listen(PORT); | |
console.log('Running on http://localhost:' + PORT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment