简体   繁体   中英

How to access current directory with Boot2Docker and Docker?

I run Docker container

docker run -it python

from which I can't see my local files.

How can I mount my current (host) directory (from which I run docker ) as current directory inside the docker container? So that I can

import file

inside the container and it will find the local file.py .

I could only find complicated solutions, where I have to explicitly mount the host directory, which seems to require absolute paths, where I'd like to type something dynamic like . as path (doesn't work).

You mean like:

docker run -v $(pwd)/:/codedir -it python

?

You can't use relative paths like "." in volume commands. If it annoys you that much, try using Docker Compose, which does allow relative paths.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM