Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Airflow change port in docker compose

Tags:

docker

airflow

I have airflow running locally on port 8080 with the following docker-compose.yaml:

version: '3.7'
services:
    postgres:
        image: postgres:9.6
        environment:
            - POSTGRES_USER=airflow
            - POSTGRES_PASSWORD=airflow
            - POSTGRES_DB=airflow
        logging:
            options:
                max-size: 10m
                max-file: "3"

    webserver:
        image: puckel/docker-airflow:1.10.9
        restart: always
        depends_on:
            - postgres
        environment:
            - LOAD_EX=y
            - EXECUTOR=Local
        logging:
            options:
                max-size: 10m
                max-file: "3"
        volumes:
            - ./dags:/usr/local/airflow/dags
            # Add this to have third party packages
            - ./requirements.txt:/requirements.txt
            # - ./plugins:/usr/local/airflow/plugins
        ports:
            - "8080:8080"
        command: webserver
        healthcheck:
            test: ["CMD-SHELL", "[ -f /usr/local/airflow/airflow-webserver.pid ]"]
            interval: 30s
            timeout: 30s
            retries: 3

However I need the port 8080 for another process. I tried updating to both "8080:8081" and "8081:8081" but neither worked, server would not respond. "8080:8080", however, works like a charm. What am I missing here?

like image 303
DBA108642 Avatar asked Oct 27 '25 15:10

DBA108642


1 Answers

I think you missed the only correct option. The syntax for ports is:

{host : container}

so in your case

8081:8080

should technically work. Assuming of course that airflow runs on port 8080 and has that one exposed (which it seems according to the dockerfile).

like image 59
JustLudo Avatar answered Oct 29 '25 07:10

JustLudo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!