Lets start with Docker in a nodes project.

Containers_DS_378x250_1We will setup  containerization which has nodes, angular2 using docker.  In here how we can deploy a simple nodes app which is built using angular2 and how it get deployed using docker on your local machine. i will provide you link to the source you need to just check out the source code and run few commands.

check out how to setup docker on mac here

  1. Checkout the project from git repo pig latin.
  2. You can open your project on any of your IDE i used VSC(visual source code) or ATOM.
  3. Create a docker file with a name DockerFile in the project adjacent to package.jason.
  4. Content of your docker file would be
FROM node:boron
# Create app directory
WORKDIR /src/app
# Install app dependencies
COPY package.json .
# For npm@5 or later, copy package-lock.json as well
# COPY package.json package-lock.json .
RUN npm install
# Bundle app source
COPY . .
CMD [ “npm”, “start” ]

5.  Now form terminal/cmdline navigate location where docker file is there.

6. Run command (don’t forget the “.”)

docker build -t username/pig latin .

7. Run command to see docker image created.

docker images

8. Now its time to run your docker container

docker run  -p 3001:3001 -d username/piglatin

9. To see your docker container running run command

docker ps  or docker ps -a (in case container dies due to some issue)

10. you will see something like this.

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                           NAMES

afd13d0898ff        nshah/piglatin      “npm start”         2 days ago          Up 2 days >3001/tcp   priceless_jang

11. Request url localhost:3001 and see the app running through your container.

Published by sbcons

Sbcons has expertise in different areas of SDLC, provide solution, services and consultancy to all type of industry.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: