Creating a Dockerfile

1 hour
  • 2 Learning Objectives

About this Hands-on Lab

In this hands-on lab, you are part of a development team that is working on a next-gen product for XYZ Company. The team needs you to Dockerize the application. To do this, you need to create a Dockerfile that will copy the code to `/var/node` where the application will live.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Clone the Application from GitHub

Clone the repo:

git clone https://github.com/linuxacademy/content-express-demo-app.git
Build the Docker Image

Create a Dockerfile:

vi Dockerfile

Dockerfile:

FROM node

RUN mkdir -p /var/node
ADD content-express-demo-app/ /var/node
WORKDIR /var/node
RUN npm install

CMD bin/www

Build the image:

docker build -t la/app-ndoe -f Dockerfile .

Additional Resources

Make sure to complete all your work on the lab server.

  1. Create a Dockerfile and configure it as follows:
    • Use Node as the base image.
    • Include the application code from content-express-demo-app, and make sure it is added to /var/node.
    • Set /var/node as the working directory.
    • Execute npm install.
    • Make sure that the start command is set to /bin/www.
  2. Build the Docker image and make sure to tag it with la/app-node.

Notes:

  • Use sudo for root access privileges.
  • All work should be done in the root directory.
  • GitHub repository URL.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?