diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..3021253dd82d7e5bcb1aa51b86fc15c6907af9a8
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,31 @@
+FROM debian:testing-slim
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+# Install build tools
+RUN apt-get update && apt-get install -y --no-install-recommends git make texinfo bison flex \
+  gettext dwarves meson python3-sphinx-rtd-theme libudev-dev pkg-config clang doxygen clang \
+  emscripten llvm
+
+# Install required libraries
+RUN apt-get install -y --no-install-recommends gcc-multilib g++-multilib libgmp-dev \
+  libmpfr-dev libmpc-dev libssl-dev libelf-dev libsqlite3-dev libasound2-dev libjpeg-dev \
+  libjson-c-dev libqt5opengl5-dev libsdl2-dev libbpf-dev libgtk-3-dev libc++-dev libc++1 \
+  libc++abi-dev libc++abi1 libclang-dev libclang1 liblldb-dev libllvm-ocaml-dev libomp-dev libomp5
+
+# Install additional utilities
+RUN apt-get install -y --no-install-recommends dvipng rsync wget clang-tidy clang-tools clangd \
+  xz-utils clang-format python3-argcomplete bc python3-clang lld lldb abi-dumper abi-compliance-checker
+
+# Install packages required for virtualization
+RUN apt-get install -y --no-install-recommends qemu-system-x86  virtme-ng
+
+RUN apt-get clean && rm -rf /var/lib/apt/lists/*
+
+
+# Move .git/refs/heads/master into the container in order to read the git hash of the current version of the build-scripts
+COPY ./cross.sh ./funcs.sh ./prepare_build.sh ./build.sh ./configs ./gitmenu.sh ./pahole*\
+  ./prepare_kernel.sh ./upload.sh ./virtme-test.sh parselog.pl .git/refs/heads/master /build-scripts/
+RUN git config --global --add safe.directory /build-scripts/media-git
+
+WORKDIR /build-scripts
diff --git a/README b/README
index c377435228d52c919499853c7683dfe5057cd3bb..3fa6197455bcb75b63c0c35ddebbe87982cf68b2 100644
--- a/README
+++ b/README
@@ -74,6 +74,17 @@ you need to.
 Once all the setup steps are performed you can start to use the
 build.sh script to test your patches.
 
+Using a container environment
+-----------------------------
+
+This project provides a Dockerfile to ease sourcing the dependencies for the different tools, to avoid clashes with your system dependencies and to enable installation on unsupported OS variations.
+With the provided `container.sh` script you can create and interact with the container.
+To build the container simply execute: `./container.sh build` and to run the container use the image tag of the container and execute: `./container.sh run <image-tag>`.
+
+The container will clone local kernel sources into the project under the folder `media-git` and will bind that folder into the container.
+In order to provide a custom `.env.sh` file, you have to fill out the example under `custom_data/env.sh`.
+
+Within the container you will have to execute `./build.sh setup` to prepare the repository before you can run tests as described below.
 
 Using build.sh
 --------------
diff --git a/build.sh b/build.sh
index 9b30b4dd31d2f96a31de8b4a9ddf26ce3e2a9426..f3a802f55f91384e8f1cb4f48e03354e8835f6f1 100755
--- a/build.sh
+++ b/build.sh
@@ -204,8 +204,10 @@ fi
 
 if [ "$1" == "setup" ]; then
 	if [ ! -d $build_data/media-git ]; then
-		echo '`media-git` folder missing, run prepare_build.sh first'
-		exit 1
+		$top/prepare_kernel.sh
+	fi
+	if [ ! -d $build_data/smatch || ! -d $build_data/v4l-utils || ! -d $build_data/edid-decode ]; then
+		$top/prepare_build.sh
 	fi
 	mkdir -p $build_data/trees
 	cd $build_data/trees
diff --git a/container.sh b/container.sh
new file mode 100755
index 0000000000000000000000000000000000000000..ab54388e19c44d068b07caaa6def272683c3a740
--- /dev/null
+++ b/container.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+IMAGE_TAG="$(date +"%Y-%m-%d")_media_build"
+
+case "$1" in
+  run)
+    if [ ! "$2" ]; then
+      echo "Usage: $0 run IMAGE_TAG"
+      exit 1
+    fi
+    mkdir -p build-data cross logs
+    podman run -it \
+    --mount type=bind,source="$(pwd)"/custom_data/env.sh,destination=/build-scripts/env.sh,readonly \
+    --mount type=bind,source="$(pwd)"/build-data,destination=/build-scripts/build-data \
+    --mount type=bind,source="$(pwd)"/cross,destination=/build-scripts/cross \
+    --mount type=bind,source="$(pwd)"/logs,destination=/build-scripts/logs \
+    "$2" \
+    /bin/bash
+    ;;
+  build)
+    mkdir -p custom_data
+    cat > custom_data/env.sh << EOF
+myrepo=git://linuxtv.org/hverkuil/media_tree.git
+name="Example Name"
+email="example@mail.com"
+EOF
+    if [ ! -d build-data/media-git ]; then
+      ./prepare_kernel.sh
+    fi
+    podman build -t $IMAGE_TAG --progress=plain . 2>&1 | tee build.log
+    ;;
+  *)
+    echo "Usage: $0 {run IMAGE_TAG|build}"
+    exit 1
+esac
+
diff --git a/custom_data/env.sh b/custom_data/env.sh
new file mode 100644
index 0000000000000000000000000000000000000000..57788914bbd0b1e2237c2bfbf31b9fdf2df70ef1
--- /dev/null
+++ b/custom_data/env.sh
@@ -0,0 +1,3 @@
+myrepo=git://linuxtv.org/hverkuil/media_tree.git
+name="Example Name"
+email="example@mail.com"
diff --git a/prepare_build.sh b/prepare_build.sh
index d719641fca438ed230e5204dbbfa1fef3e953728..39383a741390e6fe85247b2603bb19ce079faabb 100755
--- a/prepare_build.sh
+++ b/prepare_build.sh
@@ -3,11 +3,6 @@
 cd build-data
 git clone git://linuxtv.org/v4l-utils.git
 git clone git://linuxtv.org/edid-decode.git
-git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git media-git
 if [ ! -d smatch ]; then
   git clone git://repo.or.cz/smatch.git
 fi
-cd build-data/media-git
-git remote add media_tree git://linuxtv.org/media_tree.git
-git remote add media_stage git://linuxtv.org/media_stage.git
-cd ../..
diff --git a/prepare_kernel.sh b/prepare_kernel.sh
new file mode 100755
index 0000000000000000000000000000000000000000..7cf68cd5a317aa9810ad278bb24e47d340471979
--- /dev/null
+++ b/prepare_kernel.sh
@@ -0,0 +1,7 @@
+!#/bin/bash
+
+git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git build-data/media-git
+cd build-data/media-git
+git remote add media_tree git://linuxtv.org/media_tree.git
+git remote add media_stage git://linuxtv.org/media_stage.git
+cd ../..