Thanks to visit codestin.com
Credit goes to github.com

Skip to content

watchtower makes Django inside docker unaccesible #190

@benjujo

Description

@benjujo

Setting the LOGGING variable using watchtower in settings.py makes the application unaccesible from the host machine.

The way is configured (settings.py):

import boto3
...
boto3_logs_client = boto3.client(
    "logs",
    aws_access_key_id=AWS_ACCESS_KEY_ID,
    aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
    region_name=AWS_S3_REGION_NAME)

LOGGING = {
    ...
    'handlers' = {
        'watchtower': {
            'level': 'DEBUG',
            'class': 'watchtower.CloudWatchLogHandler',
                     'boto3_client': boto3_logs_client,
                     'log_group': 'the_logs_group',
                     'stream_name': "{machine_name}_{logger_name}",
            'formatter': 'aws', # 'aws' is defined in formatters
        }
    }
    ...
}

When i tried to curl to http://127.0.0.1:8000 throws:

curl: (56) Recv failure: Connection reset by peer

This behavior happens just when using watchower. If I delete the watchtower handler everything works fine.

More context:
Running docker ps seems to be OK:

CONTAINER ID   IMAGE                                COMMAND                  CREATED        STATUS          PORTS                                       NAMES
1232190abcde   docker_image_name                    "python manage.py ru…"   2 hours ago    Up 37 seconds   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp   docker_container_name

And running netstat -atpn:

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN      -
tcp6       0      0 :::8000                 :::*                    LISTEN      -

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions