Build a Docker container and save png from altair

I took a lot of trial and error, so I'll just upload the results. When I installed the latest version of chromedriver-binary, the major version was larger than google-chrome-stable and I got an error. It seems that you can use something other than stable on the Chrome side, but I decided to match chromedriver-binary with Chrome.

Dockerfile


FROM python

#Chrome installation
RUN wget -q -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' | tee /etc/apt/sources.list.d/google-chrome.list && \
    apt update && apt install -y google-chrome-stable

WORKDIR /python
COPY requirements.txt .
# chromedriver-Match major version of binary to Chrome
#     google-chrome --version: "Google Chrome 0.0.0.0"Returns a string like
#     grep --only-matching:    (In each line)Returns all the matched parts in order
#     head -n 1:Get only the major version
#     sed --in-place:I do not know
RUN sed -e s/chromedriver-binary/chromedriver-binary==`google-chrome --version | grep -o -E "[0-9]*" | head -n 1`.*/ -i requirements.txt

RUN pip install --upgrade pip && pip install -r requirements.txt

requirements.txt


altair
altair_saver
chromedriver-binary
jupyter
matplotlib
numpy
pandas
scipy==1.5
selenium

The titles should be ʻaltair, ʻaltair_saver, chromedriver-binary, selenium.

main.py


import altair
import chromedriver_binary              #PATH is passed by import;Not used as a module
altair.renderers.enable('altair_saver') #There was an argument to specify the format in the official document, but I removed it because I was angry
altair.Chart(...).....save('plot.png')  #Successful

Recommended Posts

Build a Docker container and save png from altair
Carry a Docker container
Flutter in Docker-How to build and use a Flutter development environment inside a Docker container
Build a Docker environment that can use PyTorch and JupyterLab
[Django] Build a Django container (Docker) development environment quickly with PyCharm
Build Docker environment (Linux 8) and start Apache HTTP Server container
Build a go environment using Docker
Build a deb file with Docker
Run Matplotlib on a Docker container
How to delete a Docker container
Get OCTA simulation conditions from a file and save with pandas
[DynamoDB] [Docker] Build a development environment for DynamoDB and Django with docker-compose
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server
How to split and save a DataFrame
[Linux] Build a jenkins environment with Docker
Run matplotlib on a Windows Docker container
[Linux] Build a Docker environment with Amazon Linux 2
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Trial and error]
How to run a Django application on a Docker container (development and production environment)
Build a LAMP environment on your local Docker
Build a C language development environment with a container
Install docker mongodb image and connect from spring-boot
[Python] Build a Django development environment with Docker
Use the Kaggle API inside a Docker container
Build a virtual environment with pyenv and venv
Sort Fashion-MNIST data and save as PNG file
Try Python interactive mode inside a Docker container
Build PyPy and Python execution environment with Docker
Build a Python machine learning environment with a container
[Django] Use VS Code + Remote Containers to quickly build a Django container (Docker) development environment.