Issue Starting Application As Described in the Docker Tutorial

Good Afternoon!
I am relatively new to Docker, therefore I was going through the Docker tutorial.

I was attempting to start the application as described here in the tutorial:
http://localhost/tutorial/our-application/

Where I obtained the app .zip file and placed it here: C:\Users\aetay

I then built the Dockerfile as described in the tutorial:

FROM node:12-alpine
WORKDIR /app
COPY . .
RUN yarn install --production
CMD [“node”, “/app/src/index.js”]

I was able to run the dockerfile successfully and build the container image using the command:
docker build -t getting-started .

However when I attempted to start the application using the command:
docker run -dp 3000:3000 getting-started

I noticed on the Docker dashboard the error:

internal/modules/cjs/loader.js:983
throw err;
^
Error: Cannot find module '/app/src/index.js'

at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)

at Function.Module._load (internal/modules/cjs/loader.js:862:27)

at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)

at internal/main/run_main_module.js:18:47 {

code: 'MODULE_NOT_FOUND',

requireStack: []

}

Per troubleshooting the “index.js” file is located here: C:\Users\aetay\app\src therefore not sure what else I am missing.

Please advise.
Thanks!

With WORKDIR /app and Dockerfile placed at C:\Users\aetay you’ll end up with /app/app/src/index.js in the container.

Place the .zip file in C:\Users\aetay\app instead and rebuild the Docker image.

Just to clarify:

I placed the app .ZIP file in: C:\Users\aetay\app and unzipped the ZIP file in this location so that I have this:

I placed my Dockerfile here: C:\Users\aetay\Dockerfiles

Did a rebuild using the command: docker build -t getting-started . and I ran the command from:
C:\Users\aetay\Dockerfiles

Per the Docker dashboard still seeing the Error: Cannot find module ‘/app/src/index.js’ therefore not sure where Docker is looking when the container is being started to find this index.js file (it doesn’t look like Docker is looking in: C:\Users\aetay\app\src

Thanks

Place your Dockerfile in C:\Users\aetay\app

Thanks.

After re-arranging where my Dockerfile and app ZIP was located (as shown below) in the screenshot

did a rebuild (using the command: docker build -t getting-started .)

After a successful rebuild started container (using the command: docker run -dp 3000:3000 getting-started)

End result: the application did start up

Thanks for the help.

1 Like