1

I'm playing around with Docker Compose to make a container running a Rails App with a Oracle backend.

Dockerfile and docker-compose.yml

This works great until my Docker container tries to install the ruby-oci8 gem, which looks for some oracle specific environment variables.

These variables are exposed in the oracle container's Dockerfile:

RUN 'export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe' 

The question is, how do I expose this environment variable on the oracle container to the web container?

2 Answers 2

2

The problem here is that the web container needs an oracle client to talk to the oracle database in the db container. This took a bit of doing, since oracle does not provide a client on apt-get, so I downloaded the RPMs from Oracle's site, put them in vendor/ and did the following in the dockerfile:

FROM ruby:2.2.2

RUN apt-get update && apt-get install -y build-essential
RUN apt-get install -y libxml2-dev libxslt1-dev
RUN apt-get install -y libqt4-webkit libqt4-dev xvfb
RUN apt-get install -y nodejs
# Needed for Oracle Client
RUN apt-get install -y libaio1 libaio-dev

# Required for Oracle RPMs
RUN apt-get install -y alien

# Set up app at /code
ENV APP_HOME /code
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

ADD vendor/*.rpm $APP_HOME/vendor/
# Oracle Client Environment Variables
ENV ORACLE_HOME /usr/lib/oracle/12.1/client64
ENV LD_LIBRARY_PATH $ORACLE_HOME/lib/:$LD_LIBRARY_PATH
ENV NLS_LANG American_America.UTF8
ENV PATH $ORACLE_HOME/bin:$PATH
# Set this so you don't have to type it in with rake db:create
ENV ORACLE_SYSTEM_PASSWORD myoraclecontainerspassword

# Install Oracle Client
RUN alien -i vendor/oracle-instantclient.rpm && alien -i vendor/oracle-sdk.rpm && alien -i vendor/oracle-sqlplus.rpm

ADD Gemfile* $APP_HOME/
RUN bundle install

ADD . $APP_HOME/
Sign up to request clarification or add additional context in comments.

Comments

0

Could you add a line

ENV ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe

to your web Dockerfile?

There is some discussion to support environment variables in docker-compose, but its around supporting variables from your host system in docker-compose.yml.

Nothing that would help your question is currently discussed.

https://github.com/docker/compose/issues/495

1 Comment

This touches on what the issue actually was, which is the ruby-oci8 gem requires access to an oracle client, which is not provided by the oracle xe container. I had to add some lines to the docker file to install the client from RPMs and then add the necessary environment variables for that install.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.