Directory created inside docker container not refl

2019-08-20 09:28发布

问题:

I am beginner in docker. I am trying to create docker container and there is one folder with name 'data'. When container starts then it is expected to create folder inside data with name "logs" and "hive". And these folder should reflect on host machine directory as I am specifying in docker-compose.yml file.

When I went to docker container there file system is like

/usr/src/app # ls ./data
hive  logs
/usr/src/app #

Following is my docker-compose configuration for volume

`volumes:
    - ./data/:/app/usr/data/`

On my host machine only "data" folder is created. but hive and logs are not created.

回答1:

You made a small mistake with your compose file wrongly mapping the locations, you can fix it by:

volumes:
    - ./data/:/usr/src/app/data/

Now you on-host data folder is pointed to a /usr/src/app/data inside container.