问题描述
我正在使用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概念:
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:为绑定安装和托管安装定义安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!