I have access to a powerful computer at work so naturally I want to run a chess engine on it (stockfish for now and later leela). I am trying to use docker-compose to link a stockfish image and a jupyter notebook image; then use the python-chess library to interact with the uci version of the stockfish engine. I am having difficulty linking the images with docker-compose (I am new to docker). Here is what I have tried:
I set up my directory structure as below:
├── docker-compose.yml
├── jupyter
│ └── Dockerfile
└── stockfish
└── Dockerfile
my Docker file for stockfish is from https://github.com/jessegersensonchess/stockfish-nnue-docker/blob/master/Dockerfile:
FROM ubuntu:20.04 as builder
RUN apt update && \
apt upgrade -y && \
apt-get install -y git make g++ wget && \
git clone https://github.com/official-stockfish/Stockfish && \
cd Stockfish/src && \
CXXFLAGS='-march=native' make -j2 profile-build ARCH=x86-64-bmi2
WORKDIR /Stockfish/src
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y libgomp1 wget && apt-get autoremove -y && apt-get autoclean
COPY --from=0 /Stockfish/src/stockfish /app/
COPY --from=0 /Stockfish/src/*.nnue /app/
WORKDIR /app
CMD ["./stockfish"]
My dockerfile for jupyter:
FROM jupyter/scipy-notebook
USER root
RUN ["bash","-c","source activate root && pip install python-chess"]
USER jovyan
from the stockfish directory I can build the stockfish image and confirm that the uci executable is in the WORKDIR:
sudo docker build -t stockfish .
sudo docker run -it stockfish bash
root@mycontainerid:/app# ls -1
nn-eba324f53044.nnue
stockfish <-- the uci engine executable
from the jupyter directory I can build the jupyter image and confirm that I can import the python-chess library:
sudo docker build -t jupyter/scipy-notebook .
sudo docker run -d -P jupyter/scipy-notebook
in [1]: import chess.engine <-- the library to connect to uci engines
Now I try to link the images using docker-compose. My yml file look like this:
version: '3'
services:
this_jupyter:
build: jupyter
ports:
- "8888:8888"
volumes:
- .:/home/joyvan
this_stockfish:
build: stockfish
volumes:
- .:/home/joyvan
Ive tried a few variations of the yml file without success:
sudo docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------
stockfish_this_jupyter_1 tini -g -- start-notebook.sh Up 0.0.0.0:8888->8888/tcp
stockfish_this_stockfish_1 ./stockfish Exit 0
my question is (a) why is the stockfish container not running, and (b) where will the executable be located once I successfully link to the jupyter notebook container?
UPDATE when I start the containers with docker compose (sudo docker-compose up -d) I get the following log files,
log file for jupyter:
sudo docker-compose logs this_jupyter
Attaching to leela_this_jupyter_1
this_jupyter_1 | Executing the command: jupyter notebook
this_jupyter_1 | [I 23:33:10.836 NotebookApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
this_jupyter_1 | [I 23:33:11.782 NotebookApp] JupyterLab extension loaded from /opt/conda/lib/python3.8/site-packages/jupyterlab
this_jupyter_1 | [I 23:33:11.783 NotebookApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
this_jupyter_1 | [I 23:33:11.791 NotebookApp] Serving notebooks from local directory: /home/jovyan
this_jupyter_1 | [I 23:33:11.791 NotebookApp] Jupyter Notebook 6.1.4 is running at:
this_jupyter_1 | [I 23:33:11.791 NotebookApp] http://648f6d3c8eca:8888/?token=f2d986295231a8adf0a3b3263d1177512090e2309972ca2e
this_jupyter_1 | [I 23:33:11.791 NotebookApp] or http://127.0.0.1:8888/?token=f2d986295231a8adf0a3b3263d1177512090e2309972ca2e
this_jupyter_1 | [I 23:33:11.791 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
this_jupyter_1 | [C 23:33:11.800 NotebookApp]
this_jupyter_1 |
this_jupyter_1 | To access the notebook, open this file in a browser:
this_jupyter_1 | file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html
this_jupyter_1 | Or copy and paste one of these URLs:
this_jupyter_1 | http://648f6d3c8eca:8888/?token=f2d986295231a8adf0a3b3263d1177512090e2309972ca2e
this_jupyter_1 | or http://127.0.0.1:8888/?token=f2d986295231a8adf0a3b3263d1177512090e2309972ca2e
and the log file for stockfish:
sudo docker-compose logs this_stockfish
Attaching to leela_this_stockfish_1
this_stockfish_1 | Stockfish 181020 by the Stockfish developers (see AUTHORS file)