The Web Scraping Club

The Web Scraping Club

Share this post

The Web Scraping Club
The Web Scraping Club
THE LAB #83: Camoufox as a containerized server
Copy link
Facebook
Email
Notes
More

THE LAB #83: Camoufox as a containerized server

Upgrade your scraping tech stack with Camoufox server and scale its deployment

Pierluigi Vinciguerra's avatar
Pierluigi Vinciguerra
May 16, 2025
∙ Paid
5

Share this post

The Web Scraping Club
The Web Scraping Club
THE LAB #83: Camoufox as a containerized server
Copy link
Facebook
Email
Notes
More
1
Share

In 2025, a modern scraping tech stack cannot avoid using anti-detect browsers for the hardest websites. Of course, one of them is Camoufox, which is open-source and has a good track record of successes in the field.

While we have several companies offering browsers as a service for scraping, handling for us all the infrastructure burden, the idea of using Camoufox as a server inside a container and making it scale as our operations grow is always a hot topic in our community on Discord.

In this article, I’ll create a working Camoufox container, write a test scraper that connects to it, and show the pros and cons of this approach.

Before that, let’s start with a brief intro about containers, Docker, and their use cases with web scraping.


Before proceeding, let me thank NetNut, the platinum partner of the month. They have prepared a juicy offer for you: up to 1 TB of web unblocker for free.

Claim the offer


What is a container? And Docker?

Containers have revolutionized how we deploy web scraping tools and other applications. The idea, just like it happens for virtual machines, is to create an isolated working environment for your applications.

Virtual machines emulate an entire operating system and hardware stack, meaning each VM requires its own OS installation and runs atop a hypervisor. This leads to heavier resource consumption and slower startup times.

Containers, on the other hand, share the host system’s kernel, making them significantly lighter, faster to start, and more resource-efficient. In simple terms, a container is a lightweight, standalone, and executable package that houses both an application and its environment. This means it includes the code, runtime, system tools, and libraries needed for the app to run, ensuring consistent behavior across different environments. Because the application carries its dependencies, we avoid the classic "works on my machine" problem with containers.

Docker is the dominant platform for containerization. It provides the tooling to create and run containers efficiently. Using Docker, you can package your web scraping setup (including Camoufox and all its requirements) into an image and run it anywhere Docker is available. For a web scraping project, this means you can develop locally and then deploy the exact same environment to a cloud server, confident that it will behave identically.


Thanks to the gold partners of the month: Smartproxy, IPRoyal, Oxylabs, Massive, Scrapeless, Rayobyte, SOAX, ScraperAPI and Syphoon. They prepared great offers for you, have a look at the Club Deals page.

Claim the deals


Why Containerize Web Scraping Tools?

Containers shine brightest when deployed for web services due to their horizontal scalability and easy integration with load balancers. In this scenario, containers can effortlessly scale out, distributing traffic evenly and increasing fault tolerance and availability. But what about scrapers?

A traditional scraper that crawls an entire website (or a predefined portion of it) has more or less stable resource needs over time. If this is deployed on a container and it consistently saturates its allocated resources (memory and CPU), simply spawning more identical containers will replicate rather than resolve the problem. Additionally, frequent code changes requiring container image rebuilds might introduce overhead in a traditional scraper deployment.

But containers also have several advantages:

  • Isolation and Consistency: Each scraper runs in its own isolated environment, with all dependencies pinned. This ensures consistent behavior and avoids conflicts (e.g. library versions or system libraries) between different projects or scrapers.

  • Easy Deployment: Container images can be shipped and run on any machine (local, server, or cloud) that supports Docker. This simplifies deploying scrapers to cloud services or multiple servers without manually setting up environments.

  • Resource Control: You can limit CPU and memory usage per container, which is useful when running many scrapers in parallel. If one scraper misbehaves or leaks memory, it won’t bring down the whole system – it’s confined to its container.

  • Reproducibility: The Docker image for your scraper can be versioned. This means you can roll back to a known working version of your environment if something breaks, which is important in rapidly changing scraping scenarios.

Even if your scraper doesn’t scale horizontally in a traditional sense, running it inside a container ensures it behaves predictably across various environments. If your scraper saturates resources consistently, the solution is to optimize the scraper code or adjust resource allocation per container, rather than discard containerization entirely.

Probably, deploying a scraper as an API is the best use case for combining the advantages of containerization and scalability we've just seen.

Treating scrapers as API-like microservices allows dynamic input handling, statelessness, and more flexible horizontal scaling, fully leveraging container orchestrators.

Another use case, which we’ll see in this episode of The Lab, is to set up a Camoufox server in a container and connect our Playwright scraper to it.


Need help with your scraping project?


A brief intro about containers in Docker

Creating a container image in Docker is straightforward: the key element is a simple but powerful script called a Dockerfile, which defines exactly what your container will contain and how it will run.

Let’s break down the process in three steps.

Creating the Dockerfile

Place a file named Dockerfile (with no file extension) in your project directory. This file outlines step-by-step commands that Docker uses to build the container image. For instance:

FROM python:3.10-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .

EXPOSE 8080

CMD ["python", "app.py"]

Here’s a brief explanation:

  • FROM: Specifies the base image (here, a lightweight Python environment).

  • WORKDIR: Defines the working directory inside the container.

  • COPY: Adds files from your local directory to the container image.

  • RUN: Executes shell commands, typically used to install dependencies.

  • EXPOSE: Tells Docker the port your container will listen on.

  • CMD: Specifies the default command Docker will execute when the container starts.

Building the Image

Navigate to your project directory containing the Dockerfile and run the following command in your terminal:

docker build -t my-container-image:latest .

Breaking down this command:

  • docker build: Initiates the image-building process.

  • -t my-container-image:latest: Tags your image with a meaningful name (my-container-image) and a version (latest).

  • The final dot . indicates Docker should look for the Dockerfile in the current directory.

Running Your Container

Once built, you can start a container instance from the image using:

docker run -d -p 8080:8080 my-container-image:latest

Here:

  • docker run: Starts a new container from your built image.

  • -d: Runs the container in detached mode (in the background).

  • -p 8080:8080: Maps port 8080 on your local machine to port 8080 inside the container.

  • my-container-image:latest: The name of the image you created.

Now let’s see how to apply it to our Camoufox server in Docker.


The scripts mentioned in this article are in the GitHub repository's folder 83.CAMOUFOX-SERVER, which is available only to paying readers of The Web Scraping Club.

GitHub Repository

If you’re one of them and cannot access it, please use the following form to request access.


Building the Camoufox server container

Step 1: Creating the Dockerfile

As we’ve seen before, the first step is to create the Dockerfile procedure.

Keep reading with a 7-day free trial

Subscribe to The Web Scraping Club to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Pierluigi
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More