Mac环境Docker-Compose部署Airflow 2.1.0任务日志出现大量星号问题求助
I’ve run into similar weird log formatting glitches with older Airflow versions on Docker, especially when permission mismatches or misconfigured logging handlers are at play. Let’s walk through targeted fixes for your asterisk-ridden logs:
1. Fix the Misconfigured Docker Compose Command
First, I spotted a problematic line in your x-airflow-common section: command: bash -c pip. This overrides Airflow’s default service commands (like webserver, scheduler, or worker), which is almost certainly causing unexpected container behavior. Remove this line entirely—each Airflow service should define its own command in your docker-compose file, for example:
services: webserver: <<: *airflow-common command: webserver ports: - "8080:8080" healthcheck: test: ["CMD", "curl", "--fail", "http://localhost:8080/health"] interval: 30s timeout: 30s retries: 3 scheduler: <<: *airflow-common command: scheduler worker: <<: *airflow-common command: celery worker
2. Resolve Mac UID/GID Permission Mismatch
On Mac, Docker volume permissions often break when the container’s default user (UID 50000) doesn’t match your local user’s UID. This can lead to corrupted log writes or logging errors. Create a .env file in your docker-compose directory with your local user’s credentials:
echo -e "AIRFLOW_UID=$(id -u)\nAIRFLOW_GID=0" > .env
Then restart your containers with docker-compose down && docker-compose up -d to apply the permission fix.
3. Correct Airflow Logging Config
Your empty logging_config_class is likely causing Airflow to fall back to a broken logging setup. Set it to use the official default config:
logging_config_class = airflow.config_templates.logging.DEFAULT_LOGGING_CONFIG
Even with colored_console_log = False, the colored_formatter_class might still interfere. Replace it with a standard formatter to eliminate unwanted character formatting:
colored_formatter_class = logging.Formatter
Restart your Airflow containers after updating the config to apply changes.
4. Upgrade to a Newer Airflow Version
Airflow 2.1.0 is a 2021 release with several known bugs, including edge cases with log formatting. Upgrading to a newer stable version (e.g., 2.8.x) will likely resolve this issue entirely. Update your image reference in docker-compose or .env:
AIRFLOW_IMAGE_NAME=apache/airflow:2.8.3
Run docker-compose pull to fetch the new image before restarting containers.
Verify the Fix
After applying any of these changes, trigger a test DAG and check the logs again. The asterisks should disappear once the underlying issue is resolved.
内容的提问来源于stack exchange,提问作者RDK

