Docker apache 映像,将日志存储在主机中?
Docker apache image, store logs in host?
我使用 Docker 构建一个 Apache 映像,然后使用 docker-compose 来 运行 它。我设置了 Apache access.log 和 error.log 并希望将它们存储在容器之外。目前,我使用 Volumes,但它将数据存储在容器和主机中。
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 日志数据流式传输到标准输出,这样我就不需要存储在主机中,那就更好了。
提前致谢!
检查此 post 的 Apache 配置:
https://serverfault.com/questions/711168/writing-apache2-logs-to-stdout-stderr
然后您可以使用
检查您的日志
docker logs <container>
Volumes but it stores the data both in container and host.
不一定,它应该只在主机中存储数据(并使其在容器中可见through a bind mount)
if there is a way to stream apache log data to stdout
可能是,through configuration,但这不会持久。
我使用 Docker 构建一个 Apache 映像,然后使用 docker-compose 来 运行 它。我设置了 Apache access.log 和 error.log 并希望将它们存储在容器之外。目前,我使用 Volumes,但它将数据存储在容器和主机中。
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 日志数据流式传输到标准输出,这样我就不需要存储在主机中,那就更好了。
提前致谢!
检查此 post 的 Apache 配置:
https://serverfault.com/questions/711168/writing-apache2-logs-to-stdout-stderr
然后您可以使用
检查您的日志docker logs <container>
Volumes but it stores the data both in container and host.
不一定,它应该只在主机中存储数据(并使其在容器中可见through a bind mount)
if there is a way to stream apache log data to stdout
可能是,through configuration,但这不会持久。