Gurobi with Docker Image

710 views
Skip to first unread message

Akhilesh Soni

unread,
Mar 22, 2019, 5:19:36 PM3/22/19
to Gurobi Optimization
Hi,
I am trying to build a docker image based on python and integrating Gurobi with that. Can someone provide any insight as of how to proceed?

Akhilesh Soni

unread,
Mar 22, 2019, 5:41:06 PM3/22/19
to Gurobi Optimization

FROM python:3.6

COPY gurobi8.1.0_linux64.tar.gz /

RUN tar -xzf /gurobi8.1.0_linux64.tar.gz -C /opt/ \
  && python :/opt/gurobi810/linux64/setup.py install 
ENV PATH $PATH:/opt/gurobi810/linux64/bin

I started with python as a base image and copied gurobi zip file. The process runs as fllowing:
Step 1/5 : FROM python:3.6
 ---> 70f6aab434cf
Step 2/5 : MAINTAINER Akhilesh Soni
 ---> Using cache
 ---> 998a0c3fd988
Step 3/5 : COPY gurobi8.1.0_linux64.tar.gz /
 ---> Using cache
 ---> 69284ff22a6f
Step 4/5 : RUN tar -xzf /gurobi8.1.0_linux64.tar.gz -C /opt/   && python :/opt/gurobi810/linux64/setup.py install
 ---> Running in 9e33d51227e3
python: can't open file ':/opt/gurobi810/linux64/setup.py': [Errno 2] No such file or directory
The command '/bin/sh -c tar -xzf /gurobi8.1.0_linux64.tar.gz -C /opt/   && python :/opt/gurobi810/linux64/setup.py install' returned a non-zero code: 2

Michel Jaczynski

unread,
Mar 22, 2019, 5:55:45 PM3/22/19
to Gurobi Optimization
Hi Akhilesh,

You may have an extra ':' in your command.

Here is what I usually do:

FROM python:3.6
COPY gurobi8.1.0_linux64.tar.gz /tmp
RUN mkdir -p /opt && tar xfz /tmp/gurobi8.1.0_linux64.tar.gz -C /opt
ENV GUROBI_HOME /opt/gurobi810/linux64
ENV PATH $PATH:$GUROBI_HOME/bin
ENV LD_LIBRARY_PATH $GUROBI_HOME/lib
RUN cd $GUROBI_HOME && python setup.py install

Note that in order to use Gurobi in a Docker container, you will need to use one of these options:
- a token server running outside Docker (floating license) 
- or compute server running outside Docker (compute server license),
- or Gurobi Instant Cloud (cloud license).

Michel Jaczynski

Akhilesh Soni

unread,
Mar 22, 2019, 6:31:44 PM3/22/19
to Gurobi Optimization

Thanks, Michel. Yes : was redundant but I got the same error even after removing : I am not sure what am I doing wrong.

However, I tried with your code and I got the error "No License Found". Hence, I think at least the image creation went fine.
We are going to use a token server running outside Docker(floating license).

Thanks for your prompt response. 
Reply all
Reply to author
Forward
0 new messages