paululibro Posted June 4, 2021 Share Posted June 4, 2021 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? Quote Link to comment
Squid Posted June 4, 2021 Share Posted June 4, 2021 Are you sure it's creating the file in /data and not something like /Data Quote Link to comment
paululibro Posted June 4, 2021 Author Share Posted June 4, 2021 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 Quote Link to comment
itimpi Posted June 4, 2021 Share Posted June 4, 2021 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. Quote Link to comment
paululibro Posted June 4, 2021 Author Share Posted June 4, 2021 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.