Example: Run Chrome headless browser

Run Chrome headless browser on decentralized docker container.

Install and run Planetr Gateway on your computer

To install Planetr gateway on your computer, please read the Get Started section. This can be achieved on a laptop, a desktop computer, or a cloud instance.

Install and run the Chrome headless browser docker image on Planetr decentralized cloud

Make sure Planetr gateway is installed and running on your computer.

$ planetr dcu-ps

Create and run a decentralized compute unit (DCU) on Planetr network. For this tutorial we will be using an alpine docker image planetrio/chrome-headless with chromium-headless installed. You can see the source files to build the docker image here.

$ planetr dcu-run planetrio/chrome-headless g.medium 
INSTANCE ID            STATUS    TYPE       IMAGE                       NAME   PORTS 
c2plvuv2hrandp11u5d0   Pending   g.medium   planetrio/chrome-headless     

Please wait for the status to become 'Running'

$ planetr dcu-ps
INSTANCE ID            STATUS    TYPE       IMAGE                       NAME   PORTS 
c2plvuv2hrandp11u5d0   Running   g.medium   planetrio/chrome-headless     

planetrio/chrome-headless docker image has an alias chrm to run the chromium-headless browser.

$ planetr dcu-exec c2plvuv2hrandp11u5d0 "chrm --no-sandbox --screenshot --hide-scrollbars https://planetr.io"

The above command should create a screen grab of the web site https://planetr.io (you can change this to any website URL). Check if the screenshot file screenshot.png is created within the container.

$ planetr dcu-exec c2plvuv2hrandp11u5d0  "ls -al"
total 40
drwxr-xr-x    1 chrome   chrome        4096 May 30 11:47 .
drwxr-xr-x    1 root     root          4096 May 30 06:20 ..
-rw-------    1 chrome   chrome       24920 May 30 11:47 screenshot.png

Copy the file to your local drive.

$ planetr dcu-cp-from c2plvuv2hrandp11u5d0 /usr/src/screenshot.png screenshot.png 
File copied.

Docker project at: GitHub