douketangyouzh5219
douketangyouzh5219
2019-02-27 08:34

Docker容器中的应用如何访问Windows中的DB?

已采纳

OS: Windows server 2016

I have an App wrote in Go and put in a docker container. The App has to access "D:\test.db". How can I do that?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • duanbi2760 duanbi2760 2年前

    Using docker volumes and by using the -v or --mount flag when you start your container.

    A modified example from the Docker docs:

    $ docker run -d \
      --mount source=myvol2,target=/app \
      nginx:latest
    

    you just need to replace nginx:latext with your image name and adapt source and target as you need.

    Another example (also from the docs) using -v and mounting in read-only mode:

    $ docker run -d \
      -v nginx-vol:/usr/share/nginx/html:ro \
      nginx:latest
    
    点赞 评论 复制链接分享

相关推荐