I want to use a volume mounted on my container but it throws the next error when trying to run:
docker: Error response from daemon: error while creating mount source path '/var/skeeter/templates': mkdir /var/skeeter: read-only file system.
This is my Dockerfile:
FROM maven:3-jdk-13-alpine
RUN mkdir -p /var/container/skeeter/templates
WORKDIR /project
ADD ./target/skeeter-0.0.1-SNAPSHOT.jar skeeter-0.0.1-SNAPSHOT.jar
EXPOSE 8080
CMD java -jar skeeter-0.0.1-SNAPSHOT.jar
And this is the run cmd:
docker run -t -p 8080:8080 -v /var/skeeter/templates:/var/container/skeeter/templates --name skeeter-docker-container skeeter-docker-image:latest
This is the CMD output when i'm checking the directories permissions:
ls -l /var/skeeter/
total 4 drwxrwxrwx 2 root root 4096 ago 11 16:45 templates
ls -ld /var/skeeter/
drwxrwxrwx 3 root root 4096 ago 11 16:45 /var/skeeter/
Update: I created a new Volume and used its name at -v parameter and it runned, but java app cannot find files inside the directory
/var/skeeter/templates
doesn't exist (I think even/var/skeeter
doesn't exist), and (b) that the filesystem containing/var/skeeter
(the host's/var
most likely) is mounted read-only. Are you running those twols -l
commands from a root shell on the host? – David Maze