# Airflow and Spark in Docker: Local Setup With Both UIs

> Run Apache Airflow 3 and PySpark together in one Docker image: the Airflow UI on localhost:8080, the Spark UI on localhost:4040 and the Spark History Server on localhost:18080. No docker-compose file.

Page: https://datautility.in/airflow-spark-docker
This is the Markdown copy of the page. The tool itself runs in the browser: your files are processed on your own device and are not uploaded.

**Quick answer:** Write Airflow DAGs and Spark code, run them in Docker, and see the Airflow UI and Spark UI.

## How to use the Airflow and Spark in Docker: Local Setup With Both UIs

Airflow Lab is a free Apache Airflow playground that runs on your own computer. One Docker command starts Airflow 3 with PySpark. Write DAGs in the dags/ folder and Spark or Python code in the code/ folder, run and test them from an IDE in the browser, and open the real Airflow UI and the real Spark UI. 11 short lessons take you from your first DAG to Spark inside a DAG.

1. Start the lab with the Docker commands
2. Paste the token and connect
3. Pick a lesson, then press Test DAG or Run file

## What it does

- Real Airflow 3 with the Airflow UI
- PySpark with the Spark UI
- Two folders: dags/ and code/

## Tips

- Test DAG runs the whole DAG once in the terminal. Trigger runs it through the scheduler, so you can watch it in the Airflow UI.
- Tick Keep Spark UI open before running a Spark file, then press Spark UI.
- Click a task in the DAGs tab to read its log.

## Example

Input:

```
docker run ... datautility-airflow-lab
```

Output:

```
Airflow UI, Spark UI and a code editor, ready in about a minute
```

## Frequently asked questions

### Which ports does the lab use?
Airflow UI 8080, live Spark UI 4040 (while a job runs), Spark History Server 18080 (finished jobs) and the lab connection on 8769.

### Do I need a docker-compose file?
No. One docker build and one docker run command start Airflow, PySpark and the editor together.

### What do I need to install?
Only Docker Desktop. The lab brings Airflow, Java and PySpark.

### Can I run a Spark job from a DAG?
Yes. Put the job in code/ and call it from a DAG task, for example BashOperator with python /workspace/code/job.py. The lesson Spark inside a DAG shows it.

### Where do my DAGs live?
In a Docker volume on your computer. They are kept after you stop the lab.

## Related pages

- [Airflow Lab](https://datautility.in/airflow-playground): Learn Apache Airflow free on your own computer: write DAGs and Spark code, run them in Docker, and see the real Airflow UI and Spark UI. No cloud account.
- [Learn Apache Airflow Free: Hands-On Airflow Lab](https://datautility.in/learn-airflow-free): Practise Apache Airflow hands-on, free: DAGs, dependencies, TaskFlow, schedules, retries, branching and mapping, with 11 lessons and the real Airflow UI on your laptop.
- [Airflow DAG Examples You Can Run: TaskFlow, Branching, Retries](https://datautility.in/airflow-dag-examples): Run real Airflow 3 DAG examples free: first DAG, dependencies, TaskFlow and XCom, schedules and catchup, retries, branching, dynamic task mapping, task groups and a Spark pipeline.
- [Airflow 3 Tutorial for Beginners: Free Hands-On Lab](https://datautility.in/airflow-3-tutorial): An Airflow 3 tutorial you do, not just read: 12 lessons in a browser IDE, run on a local Docker Airflow, with the real Airflow UI. Free, no cloud account.

## Topic guides

- [Free Data Engineering Playgrounds: PySpark, Delta Lake, dbt and Airflow](https://datautility.in/guides/data-engineering-playgrounds)

## Guides

- [A Free Airflow Playground: Learn Apache Airflow With Just Docker](https://datautility.in/blog/free-airflow-playground-learn-apache-airflow-docker)
- [Your First Airflow DAG: A Hands-On Tutorial for Airflow 3 (TaskFlow API)](https://datautility.in/blog/airflow-first-dag-tutorial-taskflow-airflow-3)
- [How to Run a Spark Job From an Airflow DAG (Free, in Docker)](https://datautility.in/blog/run-spark-job-from-airflow-dag-docker)
- [Airflow Schedules, Catchup and Retries Explained (With Code You Can Run)](https://datautility.in/blog/airflow-schedule-catchup-retries-explained)

Open the tool: https://datautility.in/airflow-spark-docker
