Running a mariadb container with system variables configured using a volume doesn’t work when I pass in the configuration file as a volume using the documented arguments
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/home/king_julien_13/docker/pgdp.cnf" to rootfs at "/etc/mysql/conf.d": mount /home/king_julien_13/docker/pgdp.cnf:/etc/mysql/conf.d (via /proc/self/fd/7), flags: 0x5000, data: context="system_u:object_r:container_file_t:s0:c154,c963": 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.
But when I run the same command with the -v arguments reversed (container-path:host-path), it works like a charm. This stackoverflow answer is what got me into the working command, but I’m running docker entirely on my host, unlike what is mentioned in the answer
Linux Distro: Fedora 40
Docker Version: Docker version 24.0.5, build %{shortcommit_cli}
Edit-Note:: I tried doing the same thing with podman and the same behaviour happens
They’re not a part of the command. I’ve ran the commands multiple times even without the asterisk ( i didn’t even notice if before), it’s the same result
That is already the explanation: you are trying to bind a file into a folder. You can bind a file into a file, or a directory into a directory,. The host source and the container target must be of the same type: either both files, or both directories.
Because either one of both or both don’t exist, and docker then creates the missing part as right type. I assume if both don’t exist, that docker will bind the fresh created host directory into the created container directory.