简体   繁体   中英

`docker-compose up` context not specified

When I run my docker-compose.yml file using docker-compose up , it outputs:

ERROR: The Compose file is invalid because:
Service webserver has neither an image nor a build context specified. At least one must be provided.

Before running docker-compose up I ran docker build. using a Dockerfile that was successful. So far i've only tried quitting, restarting Docker, and using docker system prune -a to remove docker images, containers, volumes, and networks.

Here's the Dockerfile:

WORKDIR /usr/local/airflow/
COPY requirements.txt ./
RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt
COPY . .

Here's the docker-compose.yml file:

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
        image: puckel/docker-airflow:latest
        restart: always
        depends_on:
            - postgres
        environment:
            - LOAD_EX=n
            - EXECUTOR=Local
        logging:
            options:
                max-size: 10m
                max-file: "3"
        volumes:
            - ./dags:/usr/local/airflow/dags
            # - ./plugins:/usr/local/airflow/plugins
            - ./plugins/:/usr/local/airflow/plugins
            - ./requirements.txt:/requirements.txt
        ports:
            - "8080:8080"
        command: webserver
        healthcheck:
            test: ["CMD-SHELL", "[ -f /usr/local/airflow/airflow-webserver.pid ]"]
            interval: 30s
            timeout: 30s
            retries: 3

        build:
            args:
                PYTHON_DEPS: "boto3==1.12.41, notebook==6.0.3, numpy==1.18.1, pandas==0.25.3, psycopg2==2.8.4"
                AIRFLOW_DEPS: "aws, postgres"

Here's the requirement.txt file:

boto3==1.12.41
notebook==6.0.3
numpy==1.18.1
pandas==0.25.3
psycopg2==2.8.4

You are missing the context parameter inside webserver.build , which should be pointing to the relative path where your Dockerfile is:

build:
  context: .
  args:
    PYTHON_DEPS: "boto3==1.12.41, notebook==6.0.3, numpy==1.18.1, pandas==0.25.3, psycopg2==2.8.4"
    AIRFLOW_DEPS: "aws, postgres"

Reference: https://docs.docker.com/compose/compose-file/#build

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM