Docker error while creating mount source path - docker

I’m trying to create nginx container with mounted volume in /var/www:
docker run --name nginx-app1 -v /var/www:/usr/share/nginx/html:ro -d -p 11080:80 nginx
And I get the error:
docker: Error response from daemon: error while creating mount source
path '/var /www': mkdir /var/www: read-only file system.
I also tried to run it with sudo, but is the same error. When I try to mount the volume in /home/username/ everything is fine.
The /var/www dir have drwxr-xr-x permissions. I working with Ubuntu 20.04 and Docker 20.10.11
Any suggestions on what might be causing the problem?

Related

Docker Run Image Error no such file or directory

i try to run a docker image with this command:
docker run 7ce2964461cc
but get this error:
docker: Error response from daemon: error creating overlay mount to /var/lib/docker/overlay2/2900f69b23f22f96e520a3c8ec8681cb092c2e52bdfbb5e261ad130de1502df4-init/merged: no such file or directory.
try docker inspect 7ce2964461cc
1 to see the port to need to map -p port_inside=port_outside
2 the env varaible ou need to set -e KEY=VALUE
3 perhars mount a file inside docker -v XX:YY

How to mount an Arvados FUSE to a Docker container as volume

I would like to add a file system view of Arvados Keep to a Docker container. I created this file system view with arv-mount and it is based on File System in Userspace (FUSE).
Approach 1
$ docker run --rm -it -v /home/test/arv:/opt ubuntu:hirsute bash
docker: Error response from daemon: error while creating mount source path '/home/test/arv': mkdir /home/test/arv: file exists.
Approach 2
I also tried bind mounts
$ docker run --rm -it --mount type=bind,source=/home/test/arv,target=/opt,bind-propagation=rshared ubuntu:hirsute bash
docker: Error response from daemon: invalid mount config for type "bind": stat /home/test/arv: permission denied.
Both approaches I tried as non-root user (I configured Docker for non-root users) and root user.
I made it working by
Adding user_allow_other to /etc/fuse.conf
Creating FUSE mount with arv-mount --allow-other /home/test/arv

Docker bind mount directory in /tmp not working

I'm trying to mount a directory in /tmp to a directory in a container, namely /test. To do this, I've run:
docker run --rm -it -v /tmp/tmpl42ydir5/:/test alpine:latest ls /test
I expect to see a few files when I do this, but instead I see nothing at all.
I tried moving the folder into my home directory and running again:
docker run --rm -it -v /home/theolodus/tmpl42ydir5/:/test alpine:latest ls /test
at which point I see the expected output. This makes me thing I have mis-configured something and/or the permissions have bitten me. Have I missed a step in installing docker? I did it via sudo snap install docker, and then configured docker to let me run as non-root by adding myself to the docker group. Running as root doesn't help...
Host machine is Ubuntu 20.04, docker version is 19.03.11
When running docker as a snap...
all files that Docker uses, such as dockerfiles, to be in $HOME.
Ref: https://snapcraft.io/docker
The /tmp filesystem simply isn't accessible to the docker engine when it's running within the snap isolation. You can install docker directly on Ubuntu from the upstream Docker repositories for a more traditional behavior.

permission denied on access /usr/share/nginx/html after volume mount using docker

I have used simple command to create nginx container with latest image.
docker run -d -p 8080:80 -v ~/myhtmlfoler:/usr/share/nginx/html nginx
Observations:
1) myhtmlfolder which is my source folder on linux (RHEL ATOMIC) host have index.html. confirmed.
2) when docker exec with cd command to /usr/share/nginx/html (or /bin/bash) i can not ls to this folder and it says permission denied. can not make any file or directory at this location. sudo not running too inside
3) at host i have root access and folder and file have 777 rights...
continuously getting 403 forbidden

docker nginx Mount -v

docker run command error: (I was knocking on the document command, Docker
version 18.03.0-ce), ask why?
docker run -p 80:80 --name mynginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/wwwlogs -d nginx
The error is as follows:
ebb97ea2c176cb1693912f54960db6281b30c95482c67df37183a8e1c618ca92
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/home/xiao/nginx/conf/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/17a9b49be13458de18ce62753d49a94a3d6dc6685af7483f6e9b2e12d20bb92c/merged\\\" at \\\"/var/lib/docker/overlay2/17a9b49be13458de18ce62753d49a94a3d6dc6685af7483f6e9b2e12d20bb92c/merged/etc/nginx/nginx.conf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
Problem is due to $PWD/conf/nginx.conf exists in your container, and command docker run -p 80:80 --name mynginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf ... is trying to replace nginx.conf in your container with nginx.conf from your host.
If you want to have a nginx server in your container with your host's nginx.conf configuration, you have to assure yourself that nginx.conf doesn't exist in container.
If it exists in containers because you're installing it in Dockerfile and you want to keep in container your host nginx.conf file anyway, you need add RUN rm -f $PWD/conf/nginx.conf to your container Dockerfile after nginx installation.
Note that I'm only showing you a possible solution for your proposal, but I cannot recommend you to do it until I know why do you need to use your nginx.conf into the file.

Resources