docker-compose:为绑定安装和托管安装定义安装 [英] docker-compose: define mount for bind mount and managed mount

查看:117
本文介绍了docker-compose:为绑定安装和托管安装定义安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用docker-compose定义我的服务。在docker中,docker volume有两个概念。首先是关于绑定安装:安装在主机存储上。

I'm using docker-compose for defining my service. In docker, there are two concepts for docker volume. Firstly is about bind mount: mount on host storage.

docker run -d --name web-app -v $HOST/location:/container/location -p 80:80 httpd:latest

其次是关于托管的挂载:抽象存储,不依赖主机。

Secondly is about managed mount: abstract storage, not depend on host.

docker run -d --name web-app -v /container/location -p 80:80 httpd:latest

我想将这些概念映射到docker-compose。这意味着在使用docker-compose时,如何定义绑定装载托管装载

I want to map those concepts to docker-compose. It means how can I define bind mount and managed mount when using docker-compose.

推荐答案

您可以在Docker Compose的部分中找到这些Docker概念: https://docs.docker.com/compose/compose-file/#/volumes-volumedriver

You can find these Docker concepts in the volumes section of Docker Compose: https://docs.docker.com/compose/compose-file/#/volumes-volumedriver

示例:

volumes:
  # Just specify a path and let the Engine create a volume
  - /container/location

  # Specify an absolute path mapping
  - ./myfolder/location:/container/location

这篇关于docker-compose:为绑定安装和托管安装定义安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆