skip to Main Content

I wish to build a docker image that can start a container where I can use both node version 14 and lz4. The dockerfile I have so far is:

FROM node:14-alpine

WORKDIR /app

RUN apk update
RUN apk add --upgrade lz4

node --version and lz4 --help seem to run ok with the docker run command – but I wanted to ask whether there is a specific WORKDIR I should be using in the dockerfile to follow any best practices (if any exist), or does it not matter what I set the WORKDIR to? Note I’m not sure of all my future requirements, but I may need to use this image to build other images in the future, so I want to ensure WORKDIR is set appropriately.

2

Answers


  1. WORKDIR should be set to set the working directory for the subsequent docker commands in dockerfile, which makes things a little easy to understand as the paths will be relative to the working directory.

    By default, / root dir is the set working directory. Without setting any other workdir, all the commands can have absolute paths which make it even more easy to understand.

    Login or Signup to reply.
  2. It doesn’t really matter much. Besides, you could always change it for your future builds.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search