I have node/express application running in docker using below docker-compose
file,
docker-compose
version: '3.8'
services:
serverapp:
build:
context: ../
dockerfile: Dockerfile
image: backend:5.1.5
container_name: server_container
ports:
- "5000:5000"
Dockerfile
FROM node:14-alpine as backend-build
WORKDIR /app
COPY package*.json ./
RUN npm install --no-package-lock
COPY . ./
RUN npm prune --production
EXPOSE 5000
# stage-2
FROM node:14-alpine
COPY --from=backend-build /app /app
WORKDIR /app
CMD ["npm", "run", "start:docker"]
after running docker-compose file, I create an image and a container successfully.
I'm able to access all APIs using POSTMAN. Now I have to read data from D:/files
(windows machine local directory) in one of the APIs.
When I hit that particular api through POSTMAN, it throws one exception which I'm capturing in node app through exception handling mechanism and I get response as below,
{
"message": "Exception occured : Error: ENOENT: no such file or directory, scandir 'D:/files'"
}
Basically, inside such directory, I have to read different files so I need to access different files as well.
How can I access windows directory and different files within it in docker container ?
Also,
This directory is configurable by my users.
eg.
config.js
export const CONFIG={
path: "D:/files"
}
My users can change it to, let's say, D:/data/files
or something else like C:/data/abc/files
or anything.
SO, How can I make it dynamic when I create container ?
FYI, in local, everything works perfectly fine. It is just docker container in which it doesn't work.