id

Errors Walk 🌱

Posted:
Table of contents:

The strange, undocumented, little known errors found during building applications.

Utilities

Service in Docker container can’t write to host filesystem

Sometimes it happenes in CentOS like distibution.

Simply add :Z to your docker volume definition to give docker permission to write.

volumes:
    - ~/app-data/:/app-data:Z

Docker service can’t talks to other services

Don’t hardcode service port, use its name.

services:
    ....
        environment:
            - KAFKA_HOST=kafka # <---- don't use `KAFKA_HOST=localhost`
            - KAFKA_PORT=9092
    kafka:
        image: wurstmeister/kafka
        ports:
            - '9092:9092'

Docker service can’t find other service

Pay attention to the whitespace in your docker-compose.yml

Code

Jinja2 loop can’t access iterables attribute and can’t do next operation

Since jinja2 can’t access iterables attribute correctly, it can’t do next operation properly such as sort.

This will not work:

<!-- Maybe because Jinja2 pipeline doesn't execute by oder as unix does? -->
{% for article in articles if article.pupular_rating|sort(attribute = 'popular_rating') %}
    ...
{% endfor %}

This works:

{% for article in articles |selectattr("popular_rating")|sort(attribute = 'popular_rating') %}
...
{% endfor %}
CS

Continue Reading:

So what do you think? Leave your comments below.