Tuesday, April 18, 2023

Running C++ Code Snippets in Jupyter Notebooks

When I first encountered C++ on Jupyter Lab, I was excited to start experimenting with the Dockerfile for the same. Previously, I posted a Dockerfile in my post Programmer's Quest: C++ in Jupyter Docker (progquest.blogspot.com), but it is outdated.

Please use the following Dockerfile going forward. This docker works fine for all C++ (C++11, C++14 & C++17):
FROM docker.io/jupyter/scipy-notebook:latest

RUN mamba install -yn base nb_conda_kernels \
    && mamba create -yn xeus-cling xeus-cling boost \
    && mamba clean -qafy

>> docker build --rm -t mycpp-jupyter .

>> docker run -it -d -p 8888:8888 --name mycpp -v <your dir>:/notebooks mycpp-jupyter