I struggle a little bit with running Canopy inside a docker container. So I thought it would be great to document how to achieve it in a separate post. I have following code which is responsible for downloading a whole page by going to it.

let fetchHtml (city) =
    startChrome ()
    url "http://www.licytacje.komornik.pl/Notice/Search"
    waitFor search
    ".city" << city
    click "#Type"
    click "Nieruchomość"
    click ".button_next_active"

    let page = browser.PageSource
    quit ()


The startChrome method looks as follows:

let private search () =
    (elements ".city").Length > 0

let private startChrome () =
    let chromeOptions = ChromeOptions()
    let chromeNoSandbox = ChromeWithOptions(chromeOptions)
    start chromeNoSandbox

As you may see I don’t use HeadlessChrome instead of it I use standard chrome and pass arguments to it to use a headless mode and no-sandbox. Which are needed.

module Auctions =
    let get =
        configuration.chromeDir <- AppDomain.CurrentDomain.BaseDirectory


That’s all from a code perspective, but I need to do some adjustments so the canopy would be run inside of a docker. To make it happen I have to do the following things:

  • copy chrome driver in a server.fsproj to output folder;
<Content Include="chromedriver.exe">
<Content Include="chromedriver">
  • install chrome in a docker image.


RUN apt-get update && apt-get install -y gnupg2 && apt-get install -y wget

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
      && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
      && apt-get update \
      && apt-get install xvfb unzip google-chrome-stable -y \
      && wget https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \
      && unzip -d /usr/local/bin chromedriver_linux64.zip

This article in short illustrates how to run canopy inside of docker container. You could check-out my repository the get the fully working example of above.