简体   繁体   中英

`docker run -v` doesn't work as expected

I'm experimenting with a Docker image repository cloned from https://github.com/amouat/example_app.git (which is based on another repository: https://github.com/mrmrcoleman/python_webapp ).

The structure of this repository is:

├── Dockerfile
 ├── example_app
 │   ├── app
 │   │   ├── __init__.py
 │   │   └── views.py
 │   └── __init__.py
 ├── example_app.wsgi

After building this repository with tag example_app , I try to mount a directory from the host in the repository:

$ pwd
/Users/satoru/Projects/example_app
$ docker run -v $(pwd):/opt -i -t example_app bash 
root@3a12236a1471:/# ls /opt/example_app/
root@3a12236a1471:/# exit
$ ls example_app
__init__.py app         run.py

Note that when I tried to list files in /opt/example_app in the container it turned out to be empty.

What's wrong in my configuration?

Your Dockerfile looks like this:

FROM python_webapp

MAINTAINER amouat

ADD example_app.wsgi /var/www/flaskapp/flaskapp.wsgi
CMD service apache2 start && tail -F /var/log/apache2/error.log

So you won't find the files you mentioned since there were non ADD -d in the Dockerfile. Also, this is not going to work unless python_webapp installs apache and creates /var/www/flaskapp and /var/log/apache2 exists. Without knowing what these other customs parts do, it is hard to know what to expect.

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