Create and bind mount file in Docker
NickName:Nicola Mori Ask DateTime:2022-06-15T01:34:49

Create and bind mount file in Docker

The Docker documentation about bind mounts states that:

The file or directory does not need to exist on the Docker host already. It is created on demand if it does not yet exist.

This is true for folders: if I bind mount as:

docker run -v $PWD/mydir:/mydir image:version

then the mydir folder is created and bind mounted in the container. But I cannot find the syntax for doing the same thing for a file either at the above linked page nor anywhere else.

Copyright Notice:Content Author:「Nicola Mori」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72621218/create-and-bind-mount-file-in-docker

More about “Create and bind mount file in Docker” related questions

Create and bind mount file in Docker

The Docker documentation about bind mounts states that: The file or directory does not need to exist on the Docker host already. It is created on demand if it does not yet exist. This is true for

Show Detail

How to create a docker bind mount / volume with spaces in the path

I want to create a bind mount, but my source path has spaces in it and because of that I can't create the bind mount because my command is not parsed correctly by docker.

Show Detail

docker-compose: define mount for bind mount and managed mount

I'm using docker-compose for defining my service. In docker, there are two concepts for docker volume. Firstly is about bind mount: mount on host storage. docker run -d --name web-app -v $HOST/loc...

Show Detail

Recreating docker bind-mount

If you bind-mount a non-existent file (on the host), docker will happily create a directory in its place and share it with the container. Upon "fixing" the mistake, (ie, stopping the container, rep...

Show Detail

Making a local bind mount in docker-compose

My team is using docker-compose for our project's container. Previously, while we were learning how Docker works, we were just using docker. In docker, I could instantly see my local changes on my ...

Show Detail

Mount docker-entrypoint.sh as bind volume

I have a docker image that I want to use and reuse when it's updated. I want to avoid making any changes to the image itself to semi-automate the process of pulling the latest image and deploying

Show Detail

Docker-compose up error: Cannot create container for service notebook: invalid mount config for type "bind": bind mount source path does not exist

I copied a docker image from computer to another, then I did a docker-compose up but I got the error below. I have done this operation before on other computers and it worked fine (just copying the...

Show Detail

Docker volume vs mount bind for external hdd

First time docker ser here, running on Raspberry Pi 3 (Hypriot OS). I have an external hdd attached to my raspberry pi to store all the files. The os is on the sdcard. I am setting up many images on

Show Detail

Docker mount type bind while build is failing

I am using docker build kit to build by docker image. I want bind the host volume to cache the libraries, I am using mount type bind. Here is my docker file. (ref from here and here) # syntax = d...

Show Detail

Docker bind mount usage

Our application is running on a unix box(let's say box1) on which one nfs filer is mounted on /var/app/data directory. Application writes some text file on the mounted directory /var/app/data. ...

Show Detail