[英]Docker-compose specify config file
I'm new to docker and now I want to use docker-compose
.我是 docker 的新手,现在我想使用docker-compose
。 I would like to provide the docker-compose.yml
script the config file with host/port, maybe credentials and other cassandra configuration.我想为docker-compose.yml
脚本提供带有主机/端口的配置文件,可能是凭据和其他 cassandra 配置。
How to specify it in the compose script:如何在撰写脚本中指定它:
cassandra:
image: bitnami/cassandra:latest
You can do it using Docker compose environment variables( https://docs.docker.com/compose/environment-variables/#substituting-environment-variables-in-compose-files ). 您可以使用Docker compose环境变量( https://docs.docker.com/compose/environment-variables/#substitute-environment-variables-in-compose-files )来完成。 You can also specify a separate environment file with environment variables. 您还可以使用环境变量指定单独的环境文件。
Apparently, including a file outside of the scope of the image build, such as a config file, has been a major point of discussion (and perhaps some tension) between the community and the folks at Docker. 显然,包括图像构建范围之外的文件(例如配置文件)一直是社区与Docker人员讨论的主要问题 (也许是一些紧张)。 A lot of the developers in that linked issue recommended adding config files in a folder as a volume (unfortunately, you cannot add an individual file). 该链接问题中的许多开发人员建议将文件夹中的配置文件作为卷添加(遗憾的是,您无法添加单个文件)。
It would look something like: 它看起来像:
volumes:
- ./config_folder:./config_folder
Where config_folder
would be at the root of your project, at the same level as the Dockerfile. 其中config_folder
位于项目的根目录,与Dockerfile处于同一级别。
If Docker compose environment cannot solved your problem, you should create a new image from the original image with COPY to override the file.如果 Docker compose 环境无法解决您的问题,您应该使用 COPY 从原始图像创建一个新图像来覆盖文件。
Dockerfile: Dockerfile:
From orginal_image:xxx
COPY local_conffile in_image_dir/conf_dir/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.