Following is my dockerfile that works to run the H2 Database: I want to create a docker compose file for this.
FROM klousiaj/oracle-java:7.79
MAINTAINER J.P. Klousia <klousiaj>
ENV DOWNLOAD http://www.h2database.com/h2-2016-10-31.zip
ENV DATA_DIR /opt/h2-data
RUN curl ${DOWNLOAD} -o h2.zip \
&& unzip h2.zip -d /opt/ \
&& rm h2.zip \
&& mkdir -p ${DATA_DIR}
EXPOSE 8082 9092
CMD java -cp /opt/h2/bin/h2*.jar org.h2.tools.Server \
-web -webAllowOthers -webPort 8082 \
-tcp -tcpAllowOthers -tcpPort 9092 \
-baseDir ${DATA_DIR}
VOLUME ${DATA_DIR}
Following is the docker compose i am trying to perform:
version: '2'
services:
db:
image: klousiaj/oracle-java:7.79
environment:
DOWNLOAD: http://www.h2database.com/h2-2016-10-31.zip
DATA_DIR: /opt/h2-data
command: curl ${DOWNLOAD} -o h2.zip \ && unzip h2.zip -d /opt/ \ && rm h2.zip \ && mkdir -p ${DATA_DIR}
expose:
- "8082-9092"
command: java -cp /opt/h2/bin/h2*.jar org.h2.tools.Server \ -web -webAllowOthers -webPort 8082 \ -tcp -tcpAllowOthers -tcpPort 9092 \ -baseDir ${DATA_DIR}
volumes:
- ${DATA_DIR}
Im getting error as :
ERROR: for db Cannot create container for service db: Invalid volume spec ".": Invalid volume destination path: '.' mount path must be absolute.
command
entries per service. You probably want to keep using your Dockerfile and then refer to that using Docker Compose'sbuild
option: docs.docker.com/compose/compose-file/#/build – nwinkler