What command do I have to type to start docker and get a shell that has access to all my files or at least the home files on the host?
For example, I'm on a mac and I want to run ubuntu's grep on a file, or execute a bash script using ubuntu bash
I have created an empty file named hello
on my host machine at ~/Desktop/tmp/files/hello
Use the -v
flag to specify volume binding and read the documentation for Using volumes . For example:
docker run --name voltest --rm -it -v ~/Desktop/tmp:/my ubuntu bash
Says:
docker run
Create a container named "voltest" --rm
delete the container when it exits -it
keep an interactive shell -v ~/Desktop/tmp:/my
Bind a volume on my machine at ~/Desktop/tmp
to the container filesystem at /my
ubuntu
Create the container using the ubuntu image bash
Run the bash
command in the container Then whenever you run:
find /my
You get:
/my
/my/files
/my/files/hello
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.