Deployment with Docker

Using Docker is a recommended way to deploy LiveGo in a consistent and isolated environment. This guide covers the details of the official Docker image and how to customize your deployment.

Understanding the Dockerfile

LiveGo's Dockerfile uses a multi-stage build to create a small and efficient final image.

  1. Builder Stage: A golang:latest image is used to build the Go binary. It downloads dependencies and compiles the livego executable.
  2. Final Stage: A lightweight alpine:latest image is used for the final container. The compiled livego binary from the builder stage is copied over. This results in a significantly smaller image size.

Exposed Ports

The Docker image exposes the following ports, which you can map to your host machine:

  • 1935: RTMP
  • 7001: HTTP-FLV
  • 7002: HLS
  • 8090: HTTP API & Control

Environment Variables

The Dockerfile sets default ports using environment variables. You can override these when running the container.

  • RTMP_PORT (default: 1935)
  • HTTP_FLV_PORT (default: 7001)
  • HLS_PORT (default: 7002)
  • HTTP_OPERATION_PORT (default: 8090)

Running the Container

The simplest way to run LiveGo is with the docker run command provided in the Quick Start guide.

docker run -d --name livego-server \
  -p 1935:1935 \
  -p 7001:7001 \
  -p 7002:7002 \
  -p 8090:8090 \
  gwuhaolin/livego

Custom Configuration

To use a custom livego.yaml configuration file, you can mount it into the container using a Docker volume.

  1. Create a livego.yaml file on your host machine (e.g., in /path/to/your/config/livego.yaml).

  2. Run the container with a volume mount. The default working directory in the container is /app.

    docker run -d --name livego-server \
      -p 1935:1935 \
      -p 7001:7001 \
      -p 7002:7002 \
      -p 8090:8090 \
      -v /path/to/your/config/livego.yaml:/app/livego.yaml \
      gwuhaolin/livego

LiveGo will automatically detect and use the mounted livego.yaml file.

Persisting FLV Archives

If you enable FLV archiving (flv_archive: true), you should mount a volume to the archive directory to persist the files outside the container.

docker run -d --name livego-server \
  -p 1935:1935 \
  -p 7001:7001 \
  -p 7002:7002 \
  -p 8090:8090 \
  -v /path/to/your/config/livego.yaml:/app/livego.yaml \
  -v /path/to/your/archives:/app/tmp \
  gwuhaolin/livego

This example assumes your livego.yaml uses the default flv_dir: "./tmp". The command maps the host directory /path/to/your/archives to /app/tmp inside the container.