Advanced Task Guides¶
This section provides practical, step-by-step guides for extending Carto-Lab Docker to handle specific, advanced tasks.
While the base container provides a robust foundation for most spatial science workflows, it is intentionally kept lean to remain stable and lightweight. These guides show you how to build upon that foundation to meet unique project requirements.
For Advanced Users
The solutions presented here may require familiarity with the command line and basic Docker concepts.
If you have a solution for a common problem that isn't listed here, please consider contributing it to our documentation!
Add selenium and webdriver¶
The base container is constructed lightweight and comes without a webdriver.
If you need a webdriver (e.g. for svg
output in Bokeh), either update the Dockerfile
or temporarily install Selenium and Chromedriver (e.g.).
Manual Steps: Chrome¶
- Install Selenium
conda activate worker_env
conda install selenium webdriver-manager -c conda-forge
- Install Chrome
apt-get update && apt-get install -y gnupg2 zip wget
curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
apt-get -y update
apt-get -y install google-chrome-stable
- Optional: Install Chromedriver
This is an optional step, since webdriver_manager
will automatically install the matching Chromedriver (see below).
Get the Chrome version and install the matching Chromedriver
google-chrome --version
Google Chrome 104.0.5112.101
- go to
- click on matching version:
-
If you are using Chrome version 104, please download ChromeDriver 104.0.5112.79
-
- copy path to
chromedriver_linux64.zip
cd /tmp/
wget https://chromedriver.storage.googleapis.com/104.0.5112.79/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
mv chromedriver /usr/bin/chromedriver
chown root:root /usr/bin/chromedriver
chmod +x /usr/bin/chromedriver
- Use in Jupyter
from bokeh.io import export_svgs
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument("--no-sandbox")
options.add_argument("--window-size=2000x2000")
options.add_argument('--disable-dev-shm-usage')
service = Service(ChromeDriverManager().install())
webdriver = webdriver.Chrome(service=service, options=options)
# Export svg in Bokeh/Holoviews
p = hv.render(my_layers, backend='bokeh')
p.output_backend = "svg"
export_svgs(p,
filename=output / 'svg' / 'graphic.svg',
webdriver=webdriver)
Note that --disable-dev-shm-usage
is necessary for Chrome to work inside Docker.