V
V
vasx32020-10-05 21:37:19
Docker
vasx3, 2020-10-05 21:37:19

How to output logs from a Docker image?

I have a docker image for crontab. Cron works stably and I can see the logs through docker logs, the log is output to stderr.
But I'm interested in how you can output logs to a file on the host in an arbitrary folder?
I tried to connect the folder in volumes, but it does not work.

I almost forgot to clarify, I work locally on a windows machine.

Dockerfile

FROM alpine:3.6

COPY config/cronjobs /etc/crontabs/root

CMD ["crond", "-f", "-d", "8"]


docker-compose.yml
crontab:
    build:
      context: ./docker/cron
    volumes:
      # попытка забиндить папку логов
      - ./docker/logs/cron:/var/log/syslog/

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vasx3, 2020-10-06
@vasx3

Abandoned the crontab image in favor of a regular cron

V
Vitaly Karasik, 2020-10-05
@vitaly_il1

In /var/lib/docker/containers/ on the host machine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question