Git Product home page Git Product logo

docker_hello_node's Introduction

The simplest node app, in docker

  • export DOCKER_ID_USER="username"

To just use it

  • docker pull $DOCKER_ID_USER/hello_node
  • docker run -d -p 8080:8080 $DOCKER_ID_USER/hello_node
  • docker ps to see what's running (node the CONTAINER ID)
  • open http://localhost:8080/
  • docker stop <CONTAINER ID>

Connecting to docker hub

  • docker login

Building the image

  • docker build -t $DOCKER_ID_USER/hello_node .
  • docker push $DOCKER_ID_USER/hello_node

Deploying to Kubernetes (optional)

  • kubectl run hello-node --image=index.docker.io/$DOCKER_ID_USER/hello_node --port=8080
  • Check the deployment is there with kubectl get deployments
  • Check the pods are up with kubectl get pods
  • Check it's running properly before exposure with kubectl exec -ti hello-node-7ddff5778f-nt2g6 curl localhost:8080
  • Expose with kubectl expose deployment/hello-node --type="NodePort" --port=8080
  • Check with kubectl get services
  • Get a full description with kubectl describe services/hello-node
  • Pull the NodePort into an environment variable for easier use with export NODE_PORT=$(kubectl get services/hello-node -o go-template='{{(index .spec.ports 0).nodePort}}') && echo NODE_PORT=$NODE_PORT
  • Open the app in a web browser: http://<IP_OF_ANY_NODE>:<NODE_PORT>/
  • Clean up with kubectl delete service,deployment hello-node

Deploying to kubernetes with the yaml file.

  • kubectl apply -f kubernetes.yaml (apply is impdepotent so use instead of create which is just for creating). Using 1 file so the service is created first which causes the container's env vars to contain service info plus scheduling should spread them between hosts.

Further Reading

The interactive tutorials on kubernetes.io are pretty good.

docker_hello_node's People

Contributors

tom-davidson avatar dependabot-preview[bot] avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.