This is a Dockerfile that will help you create a Docker image containing an installed version of the COIN-OR Optimization Suite.
This image can serve as a great base image for python programmers interested in developing optimization programs. For e.g. Python programs that use Pyomo library (or) any other optimization library that can benefit from the solvers built into this image.
Cheers!
Python 3.10 base + The following solvers from COIN-OR optimization suite :
- Osi
- Clp
- Cbc
- DyLP
- FlopC++
- Vol
- SYMPHONY
- Glpk
- Smi
- CoinMP
- Bcp
- Ipopt
- Alps
- Dip
- Bonmin
- Couenne
- MibS
- Disco
Full credits to the COIN-OR initiative, the developers and the folks who put all this together. My contribution is just to assemble the dockerfile on a Python image with a more recent version of compilers.
-
This Dockerfile is based on Python:3.10 image and has recent versions of gcc, gfortran (version 12.2.0) NOTE that these versions are post the "cxx14" era and so by default some old features will not be supported. Use the CXXFLAGS to enable cxx14 support to compile old programs (like I did in the Dockerfile) Similarly for Fortran flags (See the Dockerfile)
-
libgfortran-12-dev package is the one that comes with the python base image. So, modified the Dockerfile to suit this.
-
I have also modified the repository access to use https instead of http (in the Dockerfile). This removes http related errors from certain proxies that result in Checksum/Hash errors.
-
In the resultant docker image, the OR executables are installed in /usr/bin and the OR libraries are installed in /usr/lib
I have not published the image on docker-hub. So you will need to clone the Github repo and build it locally. Building this can take nearly 1 hour depending on your setup. Build it over lunch!
Install "Docker desktop" on your machine if you haven't already.
The instructions below work for MAC and I hope they would work for Linux as well. Windows may need little changes (for e.g. sudo is a native linux command; you need to ensure the command is run with Admin privileges in Windows)
Build the image (Need super-user/admin privilege)
git clone https://github.com/skannan-maf/optimization-suite-docker
cd optimization-suite-docker
sudo docker build -t coin-or:latest image/
Create & start a container
docker create --name=coin-or -it coin-or:latest
docker start coin-or
Now copy in any files you need:
docker cp example.mps coin-or:/tmp
Here, we are copying into the /tmp
directory inside the container. Finally,
execute a solver command.
docker exec coin-or /usr/bin/cbc /tmp/example.mps > /tmp/output
and finally, copy the output back out
docker cp coin-or:/tmp/output .
Note that you are as root by default inside the container, but this is not much of a risk inside a docker container, since it can be recreated easily.