Cannot not restart a docker container with existing mounted host directory - docker

I pulled a nginx+php container (https://hub.docker.com/r/imagine10255/centos6-lnmp-php56/) and had started that, it will create a folder to specific location i.e.(D:\xampp\htdocs\centos6-lnmp-php56\home\website), but now i can't restart it, anyone know how to do restart it with out deleting the folder above ?
error message is here:
Error response from daemon: Cannot restart container centos6-lnmp-php56: error while creating mount source path '/c/Users/hkveg/Documents/Kitematic/centos6-lnmp-php56/home/website': mkdir /c/Users/hkveg/Documents/Kitematic/centos6-lnmp-php56: file exists
command tried:
$ docker restart centos6-lnmp-php56
Error response from daemon: Cannot restart container
centos6-lnmp-php56: error while creating mount source path
'/c/Users/hkveg/Documents/Kitematic/centos6-lnmp-php56/home/website':
mkdir /c/Users/hkveg/Documents/Kitematic/centos6-lnmp-php56: file
exists
As same as mysql container:
$ docker restart mysql
Error response from daemon: Cannot restart container mysql: error
while creating mount source path
'/c/Users/hkveg/Documents/Kitematic/mysql/var/lib/mysql': mkdir
/c/Users/hkveg/Documents/Kitematic/mysql: file exists

Related

docker run -v throws permission denied error

I am running a docker container with a volume mounted (-v) which is a mounted directory on network (NAS). This mount point has write access provisioned to the user which runs docker process on the server.
However when I run the container as docker run -v path1:path2:z I get permission denied error on path1.
Error - docker: Error response from daemon: error while creating mount source path 'path1': mkdir 'path1': Permission Denied

error while creating mount source path '/var/lib/rancher'

I installed Rancher Server in a Docker. In the configurations steps, as it's necessary, I am trying to add host:
But when I run the command below, it results in the following error:
docker: Error response from daemon: error while creating mount source path '/var/lib/rancher': mkdir /var/lib/rancher: read-only file system.

Docker mounting /tmp/pulseaudio gives error

I am trying to get sound out of my docker container. I am working on a Raspberry4 with Ubuntu 20.10.
When starting the container, I am using following lines to mount soundfile folders:
-v /tmp/pulseaudio.socket:/tmp/pulseaudio.socket
-v /tmp/pulseaudio.client.conf:/etc/pulse/client.conf
However, I am getting the following error:
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:367: starting container process caused:
process_linux.go:495: container init caused: rootfs_linux.go:60:
mounting "/tmp/pulseaudio.socket" to rootfs at
"/var/lib/docker/overlay2/cde617898e2ee8e181a48cf84db8dbcdf5bfdf57e5760493f7c5fce1640b59d5/merged/tmp/pulseaudio.socket"
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.
How can I fix this issue?
It seems you are trying to mount something that not exist in the host to a file that exist in the docker.
In this case the behaviour is (see here):
If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v will create the endpoint for you. It is always created as a directory.
So docker will create a folder in the host and try to mount it to a file in the container, and this is why you get error.
To fix it, you just need to check that the file is exist in the host, in your case /tmp/pulseaudio.socket and maybe also /tmp/pulseaudio.client.conf.
Please note that with -v the left path is for the host and the right is for the container.
-v /path/in/host:/path/in/container

Docker container corrupted

by mistake i remove some files from overlay folder in /var/lib due to size increases.
now i am not able to run docker-compose build, up or even not able to login to container.
i am getting below error.
docker-compose -f docker-compose-jenkins.yaml up
ERROR: stat /var/lib/docker/overlay2/ef7f3084c8db586b88d5f825114c144effed007be79da415629838ad77363177:
no such file or directory
docker exec -it 59dcdc4e2fba bas
Error response from daemon: readlink /var/lib/docker/overlay2/l/W5MHBAJA75EJKO7OPSB6TQ6DXU: no such file or directory
docker-compose ps
ERROR:
Can't find a suitable configuration file in this directory or any
parent. Are you in the right directory?
Supported filenames: docker-compose.yml, docker-compose.yaml
even jenkins jobs are also failing.

How to get a docker log file from a container which will exit after start?

I have a container, it will exit caused by core dumped. However I want to get a log from container path /opt/big/err.log
If I start the container, it will core dumped and exit quickly.
And I tried to mount the directory using docker run -v $(pwd)/log:/opt/big but if I add this mounting there is error
Docker Error response from daemon: OCI runtime create failed
Is there any way to get this log file out?
try to copy using:
docker cp CONTAINER_NAME:/opt/big $(pwd)/log

Resources