HackerRank DevOps Interview Solution of Docker: Node Deployment


Docker: Node Deployment


You want to deploy a web application using Docker.  As part of the process, complete a file stub "/home/ubuntu/1090236-docker-node-deployment/Dockerfile" with one or more steps that do the following:

  • Inherit a "node" image (from Dockerhub) on the "12" tag.
  • Copy the "application" folder with all contents to the "/application" path.
  • Change the working directory context to "/application"
  • Execute the "npm install" command.
  • Override "CMD" (in "exec" form) to run the "node" executable with "application.js" as its parameter.
  • Expose port "8000" to the outside.


  • The completed solution will be evaluated in a new, clean environment. Be sure everything is in the "/home/ubuntu/1090236-docker-node-deployment" folder.
  • All the tasks should be done within a simple "sudo solve" execution invoked from the question directory.
  • You have sudo access.


  • The execution result of "sudo solve" invoked from the question directory solves the task.
  • The execution result of "wget -qO- http://localhost:8000/api/token" shows a valid JSON output.


At first ssh into the server

ssh [email protected]

Then type ls and go to docker node deployment folder

You can see a Dockerfile here. Edit it

vi Dockerfile

FROM node:12-alpine
WORKDIR /application
COPY /application /application
RUN npm install
CMD [ "node", "application.js" ]

Then run this command

sudo solve

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment


Post a Comment