liveBook · Manning

Docker Compose

As explained in Build Python Web Apps with Streamlit

Docker Compose is a Docker tool for defining and running applications composed of one or more containers through declarative configuration.

Docker Compose is a configuration manager for Docker. Instead of repeatedly typing long commands, you describe an application's services, build instructions, ports, and volumes in a human-readable YAML file named docker-compose.yml. section 12.2.6

A Compose configuration can preserve the important parts of a Docker run setup:

  • Define a service, such as fact-frenzy-app. section 12.2.6
  • Build the image from the Dockerfile in the current directory with build: .. section 12.2.6
  • Map host port 8502 to container port 8501 and mount the host .streamlit directory at /app/.streamlit. section 12.2.6
Listing 12.4 The docker-compose.yml file
services:
  fact-frenzy-app:
    build: .
    ports:
      - "8502:8501"
    volumes:
      - ./.streamlit/:/app/.streamlit

Use the Compose listing to inspect the complete service, port mapping, image build instruction, and configuration volume mount. section 12.2.6

Starting the application

Running docker-compose up builds the image when necessary, starts the container with the declared settings, and makes the Streamlit application available at http://localhost:8502 with its secrets configured. section 12.2.6

How Build Python Web Apps with Streamlit covers it

How deep it goes
Defines services and runtime settings through YAML, but does not descend into Docker Compose internals or multi-service orchestration.
Examples
Uses a fact-frenzy-app service, port mapping 8502:8501, and a .streamlit volume mounted into the container.
What it assumes
Assumes familiarity with Docker images, containers, Dockerfiles, docker build, and docker run before replacing commands with configuration.
What you can do after
Operate/configure a Dockerized Streamlit app through docker-compose.yml and start it with docker-compose up.
How it connects
Connects Docker Compose with Dockerfiles, images, containers, YAML, ports, volumes, and Streamlit configuration.

Also explained in

Compare how 15 books explain Docker Compose →

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.