June 4, 20215 yr Hi. Yesterday I started learning Docker for development purposes. I created simple app with Node.js server and SQLite database on backend and React on frontend. App is creating db.sqlite file in /data directory which I wanted to mount to access the file. However when I open directory on host side, the file is not there. I've been working on it for the last 4 hours and can't figure out what I'm doing wrong. Here is mu Dockerfile. Right now I'm building React app manually. FROM node:14-alpine WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN mkdir ./public ./data RUN mv ./client/build/* ./public RUN rm -rf ./client EXPOSE 5000 CMD ["node", "server.js"] I'm then starting the container with: docker run --name app -p 5030:5000 -v /mnt/user/appdata/users:/data username/usersapp When container is running and I console into it I can run ls /data and I can see the database file being there but it's not in the /mnt/user/appdata/users Is there something fundamentally wrong I'm doing here?
June 4, 20215 yr Author 9 minutes ago, Squid said: Are you sure it's creating the file in /data and not something like /Data I’m sure it’s being written to /data
June 4, 20215 yr According to your screen shots the ‘data’ folder inside the container is not relative to the / folder inside the container but in a folder relative to a home folder, but the Docker run command IS mapping it at the host level to be relative to /. That will be why you are seeing what you describe.
June 4, 20215 yr Author 41 minutes ago, itimpi said: According to your screen shots the ‘data’ folder inside the container is not relative to the / folder inside the container but in a folder relative to a home folder, but the Docker run command IS mapping it at the host level to be relative to /. That will be why you are seeing what you describe. After changing it from :/data to :/app/data it’s working now. I read through all these articles and code examples and I was sure all the mappings were relative to the WORKDIR. Thanks for help
Archived
This topic is now archived and is closed to further replies.