Docker Apache映像,是否将日志存储在主机中? [英] Docker apache image, store logs in host?
问题描述
我使用Docker构建Apache映像,然后使用docker-compose运行它.我设置了Apache access.log和error.log,并希望将它们存储在容器之外.目前,我使用的是Volumes,但它同时将数据存储在容器和主机中.
I use Docker to build an Apache image, and then use docker-compose to run it. I set up Apache access.log and error.log and want to store them outside of the container. currently, I use Volumes but it stores the data both in container and host.
docker-compose.yml
docker-compose.yml
version: '2'
services:
web:
image: apache
build: .
container_name: my-image
volumes:
- "/var/log/my-app:/var/log/apache2"
restart: always
ports:
- "8000:80"
我的问题是如何仅将apache日志数据存储在主机中,如果有一种方法可以将apache日志数据流传输到stdout,这样我就不需要将其存储在主机中会更好.
My question is how to only store apache log data in a host, and It woule be better if there is a way to stream apache log data to stdout so that I don't need to store in the host.
提前谢谢!
推荐答案
具有卷,但它同时将数据存储在容器和主机中.
Volumes but it stores the data both in container and host.
并非如此,它仅应将数据存储在主机中(并使数据在容器中可见通过绑定安装)
Not really, it should only store data in the host (and makes it visible in the container through a bind mount)
如果有一种方法可以将Apache日志数据流式传输到stdout
if there is a way to stream apache log data to stdout
可能是的,通过配置,但这并不是永久性的.
Possible yes, through configuration, but that would not be persistent.
这篇关于Docker Apache映像,是否将日志存储在主机中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!