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.
Related
On my windows notebook I try to share a folder with my docker container, but I am getting a weird error message that does not tell me anything.
docker run -p 9999:9999 -it msmint/msmint:latest -v c:/Users/swacker/MINT:/data/
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "-v": executable file not found in $PATH: unknown.
The /data folder in the docker file is present and I gried different formats for the windows path such as C:\User\swacker\MINT.
It complains that an executable file is not found, but I don't know which one.
Options for docker need to go before the image name. Anything after the image name is a command for the container and replaces any defined CMD in the image.
So you need to do
docker run -p 9999:9999 -it -v c:\Users\swacker\MINT:/data/ msmint/msmint:latest
I've changed the slashes in your Windows path to backslashes.
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?
Trying to run masquitto Docker container on Windows. I have directory structure:
..
mosquitto
config
-- mosquitto.conf
data
log
I run command:
docker run -it -p 1883:1883 -p 9001:9001 -v mosquitto.conf:/mosquitto/config/mosquitto.conf -v /mosquitto/data -v /mosquitto/log eclipse-mosquitto
Got error:
docker: Error response from daemon: source /var/lib/docker/overlay2/c54f317f73085489398e1b2c4ffbc85fbdb18073e8a0fa60f11a7f7222fbc49d/merged/mosquitto/config/mosquitto.conf is not directory.
See 'docker run --help'.
What I do wrong?
UPD
I tried to provide full path to config file on host machine:
docker run -it -p 1883:1883 -p 9001:9001 -v C:/docker_tst/eclipse-mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto
Got error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: rootfs_linux.go:59: mounting "/run/desktop/mnt/host/c/docker_tst/eclipse-mosquitto/mosquitto.conf" to rootfs at "/var/lib/docker/overlay2/d9a7cbcb0f85b195dc5ee2d0999b3df8c84324552f6c45cf218876e9b96ed826/merged/mosquitto/config/mosquitto.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.
PS C:\docker_tst\eclipse-mosquitto>
From the comments, the solution was to provide an absolute path to the single mounted file, per this answer.
On Unix based systems or in Windows Subsystem for Linux, you can do this by running something like:
docker run -v $PWD/filename:/path/in/container IMAGE_NAME
However, the process is different on Windows, per this answer.
In PowerShell, you can run Get-Location or pwd to get the current directory where your file is and switch the \ to / (forward slashes). For this example, the solution was to use this command:
docker run -it -p 1883:1883 -p 9001:9001 -v C:/docker_tst/eclipse-mosquitto/mosquito/config/mosquito.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto
Docker volume mount fails with the below error.
I'm trying to run a container with a config file in the volume and it fails with the below errors.
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data:/var/gerrit/etc/ forkub
error: could not lock config file /var/gerrit/etc/gerrit.config: Permission denied
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data:/var/gerrit/etc forkub
error: could not lock config file /var/gerrit/etc/gerrit.config: Permission denied
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data/:/var/gerrit/etc forkub
error: could not lock config file /var/gerrit/etc/gerrit.config: Permission denied
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data/:/var/gerrit/etc/ forkub
error: could not lock config file /var/gerrit/etc/gerrit.config: Permission denied
root#ip-172-31-21-249:~/data# docker run -it -p 8080:8080 -p 29418:29418 -v /root/data/:/var/gerrit/etc/gerrit.config forkub
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/root/data\\\" to rootfs \\\"/var/lib/docker/overlay2/0a5356aed5a1aa1d1359912ccba7547db55b0377b3a509b898828734868e335a/merged\\\" at \\\"/var/lib/docker/overlay2/0a5356aed5a1aa1d1359912ccba7547db55b0377b3a509b898828734868e335a/merged/var/gerrit/etc/gerrit.config\\\" 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.
ERRO[0000] error waiting for container: context canceled
Any suggestions on fixing this is really appreciated.
Thank you,
Anish
Probably the process in the container does not run as root but as some other user. The file belongs to root though and is not readable by the user that runs the process. So the process can not read the file.
So you need to make sure that the user that runs the process in the container can access those files. The easiest way would be to make /root/data world read-/writeable (chmod -R 777 /root/data) but this is obviously not the best way. The right way to do this, would be to find out which user is running the process in the container and change the ownership of /root/data and everything in it to that user.
The problem with docker run -it -p 8080:8080 -p 29418:29418 -v /root/data/:/var/gerrit/etc/gerrit.config forkub is, that you are trying to mount a directory /root/data to a file. This does not work.
There are two ways of passing arguments, I chose this one:
sudo docker run -d -e url=http://example.com --name myBlog -p 3001:2368 -v "$(pwd)/content":/var/lib/ghost/content ghost:latest
How can I add an extra command line so it also adds a bind-mount to:
$(pwd)/testFolder/config.production.json the file on the volume would be here: :/var/lib/ghost/config.production.json
Also the file on the host doesn't exist yet, once I mount the container, it the container creates it.
This is what I've tried:
sudo docker run -d -e url=http://example.com --name myBlog6 -p 3006:2376 -v "$(pwd)/content6":/var/lib/ghost/content -v /home/ubuntu/config6:/var/lib/ghost/config.production.json ghost:latest
But I'm getting this error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/home/ubuntu/config6\\\" to rootfs \\\"/var/lib/docker/overlay2/f8c4ed9231552e91caaeb4f0b8fb9f02108f838e94b659bf049a2df365cd26ef/merged\\\" at \\\"/var/lib/docker/overlay2/f8c4ed9231552e91caaeb4f0b8fb9f02108f838e94b659bf049a2df365cd26ef/merged/var/lib/ghost/config.production.json\\\" 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.
Thanks
If I got it correctly, you get this error because you are trying to mount directory /home/ubuntu/config6 to a file ...config.production.json.
If you say that file config.production.json will be created and it's content is written in run time after the container is initialized, then you could try to created an empty file
touch /home/ubuntu/config6/config.production.json
sudo chmod 777 /home/ubuntu/config6/config.production.json
and then mount a file to the container
sudo docker run -d \
-e url=http://example.com \
--name myBlog6 -p 3006:2376 \
-v "$(pwd)/content6":/var/lib/ghost/content \
-v /home/ubuntu/config6/config.production.json:/var/lib/ghost/config.production.json \
ghost:latest
And after container will write a content to file, you will be able to see it and load next time to the container.
The chmod command is used to make sure, that you app running inside of the container will have rights to write to this file.