Home > Software > How to Get Started with Docker Compose & FFmpeg

How to Get Started with Docker Compose & FFmpeg

Anastasios Antoniadis

Kickstart your journey with Docker Compose and FFmpeg through our detailed guide. Learn how to seamlessly integrate FFmpeg into Docker containers for video processing, transcoding, and streaming projects.

Docker (1)

FFmpeg is a powerful and versatile command-line tool that can process videos, audio files, and images. It allows users to convert media files between different formats and provides many options to control the conversion process. However, setting up FFmpeg can be inconsistent across different environments, causing problems with usage and results. Docker, with its containerization technology, offers a solution by enabling users to run FFmpeg in a consistent, isolated environment, regardless of the system they’re using. This article will guide you through setting up FFmpeg using Docker Compose. It will provide a practical example to help you get started.

Understanding Docker Compose

Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services, networks, and volumes. Then, with a single command, you create and start all the services from your configuration. This method is particularly beneficial for complex applications requiring multiple services to run.


Before proceeding, ensure you have Docker and Docker Compose installed on your system. Docker Compose comes bundled with Docker for Windows and Docker for Mac, but you might need to install it separately on Linux.

Setting Up FFmpeg with Docker Compose

To run FFmpeg within a Docker container, use an existing FFmpeg image from Docker Hub or create a custom Dockerfile to build your own. For this example, we’ll use the jrottenberg/ffmpeg image, which is a popular, regularly updated FFmpeg Docker image.

Step 1: Create a Docker Compose File

Create a file named docker-compose.yml in your project directory and open it in your text editor. Define the FFmpeg service as follows:

version: '3'
    image: jrottenberg/ffmpeg
      - ./data:/data
    command: >
      -i /data/input.mp4
      -c:v libx264
      -preset fast
      -c:a aac

In this example, the volumes directive mounts the ./data directory on your host to /data inside the container, allowing FFmpeg to access the input files and write the output files to your host. The command specifies the FFmpeg command to be run when the container starts, including input and output file paths, video codec (-c:v libx264), preset, and audio codec (-c:a aac).

Step 2: Running the FFmpeg Container

Navigate to the directory containing your docker-compose.yml file and run the following command:

docker compose up

This command will pull the jrottenberg/ffmpeg image from Docker Hub (if it’s not already on your system), create a container, and run the specified FFmpeg command. FFmpeg will process the input.mp4 file in the ./data directory and output output.mp4 to the same directory.

Customizing Your Setup

The beauty of Docker Compose is in its flexibility. You can easily modify the command in the docker-compose.yml file to perform different FFmpeg tasks, such as changing formats, compressing videos, or extracting audio. Additionally, you can define other services in the same docker-compose.yml file, making it easy to integrate FFmpeg with other applications and services in your workflow.


By leveraging Docker Compose, you can simplify the deployment and execution of FFmpeg, ensuring a consistent environment across different systems and projects. This setup makes it easier to manage and scale your media processing tasks and enhances collaboration by eliminating the “it works on my machine” problem. Whether you’re a seasoned developer or a multimedia enthusiast, Docker Compose and FFmpeg can significantly streamline your video processing workflows.

Anastasios Antoniadis
Follow me
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x