AWS/azure (ubuntu) + Docker + Nodejs + Loadbalancer

Posted on Actualizado enn

  • Installing Docker in Ubuntu
    • In ec2(aws)/virtualmachine(azure) create a ubuntu server
    • Login to console using bitvise (ubuntu/publickey/global3[yourkey]), in Azure you can use a password too.
    • $ sudo apt-get update # Fetches the list of available updates
      $ sudo apt-get upgrade # Strictly upgrades the current packages
      $ sudo apt-get dist-upgrade # Installs updates (new ones)
    • $ sudo curl -fsSL | sh
    • $ sudo docker version
      • optional: down a hello image and run (copy to local)
      • $ sudo docker run hello-world
    • list image / containers
    • $ sudo docker images  / sudo docker ps -a
    • Create the image to upload to docker hub
  • NodeJS – server.js
var express=require('express')
var PORT=8080;
var app = express();
app.get('/', function(req,res){
	res.send('hi mother');
console.log('running on local '+PORT);
  • NodeJS – Package.json to configure needs
  "name": "hello",
  "version": "1.0.0",
  "main": "server.js",
  "author": "hemc",
  "description": "",
  "dependencies": {
    "express": "^4.15.2"
  • Dockerfile (without extensión)
FROM node:6.9.4
RUN npm install nodemon -g
COPY package.json /app/package.json
RUN npm install
COPY server.js /app
CMD ["nodejs", "/app/server.js"]
    all 3 in same folder, for example
  • Then we build the container image with a user to upload to dockerhub, local image name:
  • ~/nodeHello$ sudo docker build -t minode/test4 .  (point at the end)
  • Upload to docker hub
    • $sudo docker run -it minode/test4
      • new console
    • $sudo docker ps -a
      • containerid my user on dockerhub web image name
    • $sudo docker commit e1078f8d0cfb minode/onlinetest4
    • $sudo docker run -it minode/onlinetest4
      • uploading
    • $sudo docker login –username=minode
      • +password
    • $sudo docker push minode/onlinetest4

=============docker aws===============

  • Create cluser
    • t2 micro / instances 2 / key pairs (your keys) / port range 8080
  • Create task
    • default values
    • create container
      • default + minode/test4
  • Create service (back to cluster first tab)
    • numtask=4
  • Review EC2 / instances, verify inbound rules are port 8080 open
  • Verify ip:8080 of two instance
  • Loadbalancer
    • select vpc with access to zone where the instances are placed, security group with port 8080 open a follow loadbalancer classic tutorial
  • Delete cluster
    • Delete cluster in main page
    • Go inside task two times and desregister task
    • Delete load balancer and verify instances are deleted
  • To delete images
    • $ sudo docker rmi

Part 1

Part 2

Part 3

Part 4

(by the way, mute the videos, I was listening spain radio)



You can login into container with:

docker exec -it bash
and run:

apt-get update
apt-get install nano

Docker images are delivered trimmed to bare minimum – so no editor is installed with the shipped container. That’s why there’s a need to install it manually.

To show only running containers use:
docker ps
To show all containers use:
docker ps -a



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s