liveBook · Manning

Docker-compose.yml

As explained in Build Python Web Apps with Streamlit

A docker-compose.yml file is a YAML configuration file that defines services, builds, networking, and other settings for Docker Compose.

A docker-compose.yml file is a human-readable YAML configuration that records how Docker should build and run an application. It replaces repeated terminal commands with reusable instructions for services, images, ports, and mounted files. section 12.2.6

Listing 12.4 The docker-compose.yml file
services:
  fact-frenzy-app:
    build: .
    ports:
      - "8502:8501"
    volumes:
      - ./.streamlit/:/app/.streamlit

This configuration defines a fact-frenzy-app service, builds from the current directory, maps host port 8502 to container port 8501, and mounts local Streamlit settings into the container. section 12.2.6

Start the configured application

Run docker-compose up from the project directory. Docker Compose builds the image when necessary, starts the container, applies the port mapping and volume mount, and makes the Streamlit app available at http://localhost:8502. section 12.2.6

Adapt the configuration when moving from local Docker usage to Elastic Beanstalk:

  • Replace the local .streamlit volume source with /var/app/secrets/.streamlit, where Elastic Beanstalk creates the secrets file. section 12.3.5
  • Recognize that a local filesystem mount works with docker-compose up but cannot provide the same file directly in Elastic Beanstalk. section 12.3.5

How Build Python Web Apps with Streamlit covers it

How deep it goes
Defines services, builds, port mappings, and volumes, then adapts mounts for Elastic Beanstalk without detailing YAML syntax broadly.
Examples
Uses a Streamlit service with port 8502:8501 and a .streamlit volume, then changes the mapping to port 80 for Elastic Beanstalk.
What it assumes
Assumes a Dockerfile and basic Docker commands, while introducing Compose as a simpler configuration-based alternative.
What you can do after
Operate Docker applications through docker-compose up with configured builds, networking, and mounted Streamlit secrets.
How it connects
Connects Docker Compose with Dockerfile, Docker image, Docker container, Streamlit configuration, volumes, and Elastic Beanstalk.

Also explained in

Compare how 5 books explain docker-compose.yml →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.