How to stream logs from multi-container Elastic Beanstalk setups to Cloudwatch?

Viewed 106

I'm running a multi-container Docker app (Nginx, PHP-FPM, imgproxy) and want to have all my nginx and PHP error logs in CloudWatch.

In nginx, I've set error_log to /var/log/nginx/error.log warn and then created a volume in my docker-compose.yml:

services:
  web:
    image: nginx:latest
    ports:
      - 80:80
    volumes:
      - ./backend:/var/www/html
      - ./var/log/eb-docker/containers/web:/var/log/nginx
      - socket:/var/run/php-fpm
  php:
    build:
      context: ./.docker/php-fpm
      args:
        - ENV=production
    volumes:
      - ./backend:/var/www/html
      - ./var/log/eb-docker/containers/php:/var/log/php-fpm
      - socket:/var/run/php-fpm

Then I've created the Cloudwatch streaming config files, but this doesn't do anything because /var/log/eb-docker/containers/web and /var/log/eb-docker/containers/php is empty on the Docker host.

I did this for my local machine too, but with ./.logs/web:/var/log/nginx and this works fine. Is there anything that I've missed?

Edit 1

Ok, the directory is not really empty. Looking at the host, the log folders contain the following:

enter image description here

But inside my Docker container it's:

enter image description here

I think I've configured it as written in the documentation, but it doesn't work that way

Edit 2

Oh. My. Gosh. I should remove . before /var ...

0 Answers
Related