4

I would like to use a prod.conf file in production inside a Docker container. I added this to my Dockerfile:

ENTRYPOINT ["bin/myapp", "-D", "config.resource=prod.conf"]

But I got this error:

Bad root server path: /opt/docker/-D

I get the same error when I try to run the command manually as root

/opt/docker/bin/myapp -D config.resource=prod.conf

If I run

/opt/docker/bin/myapp

It works but using the default application.conf file.

I guess there is no permission issue.

Here is my full Dockerfile:

FROM openjdk:8u121-alpine
WORKDIR /opt/docker
ADD opt /opt
RUN ["chown", "-R", "daemon:daemon", "."]
EXPOSE 9000
USER daemon
ENTRYPOINT ["bin/myapp", "-D", "config.resource=prod.conf"]
CMD []

Edit:

I got the same error locally:

activator clean stage
target/universal/stage/bin/myapp -D config.resource=prod.conf
Bad root server path: /home/me/Documents/MyApp-D
4
  • not sure about your ADD opt /opt should perhaps be ADD /opt /opt? Commented Apr 18, 2017 at 9:45
  • @user2915097 nop. the opt directory isn't in my /opt directory. this is run at staging.
    – didil
    Commented Apr 18, 2017 at 9:48
  • before dockerizing, make sure the app runs successfully on your local machine. i.e. sbt stage /path/to/bin -D config.reousce=prod.conf if this won't start the app, docker will surely fail
    – LiorH
    Commented Apr 18, 2017 at 19:19
  • @LiorH I forgot to say that this is related to a prod mode for Play and not related to the Docker. The detail about the Docker container is just a clue. I do have the same error in local.
    – didil
    Commented Apr 20, 2017 at 10:05

3 Answers 3

2

There should be no space between the -D and the config value. Use this instead:

ENTRYPOINT ["bin/myapp", "-Dconfig.resource=prod.conf"]
4
  • ["bin/myapp", "-D", "config.resource=prod.conf"] and ["bin/myapp", "-Dconfig.resource=prod.conf"] are strictly equivalent.
    – didil
    Commented Apr 20, 2017 at 9:54
  • @didil Have you tried it? First should result in bin/myapp -D config.resource=prod.conf, the second will result in bin/myapp -Dconfig.resource=prod.conf.
    – Salem
    Commented Apr 20, 2017 at 9:58
  • yes I already tried it but I knew it was equivalent. the space after an option is always optional.
    – didil
    Commented Apr 20, 2017 at 10:02
  • Just to make sure: if you run inside the container /opt/docker/bin/myapp -D config.resource=prod.conf and /opt/docker/bin/myapp -Dconfig.resource=prod.conf you get the same error?
    – Salem
    Commented Apr 20, 2017 at 10:06
1

JAVA_OPTS shall be used to avoid such errors.

JAVA_OPTS="-Dconfig.resource=prod.conf" bin/myapp

Worsk with command line, systemctl.

0

If you use sbt plugin "DockerPlugin" you can type

dockerEntrypoint := Seq("")

in your build.sbt file. It will cause

ENTRYPOINT [""]

in your Dockerfile. So, then you run docker with your image you should specify in run command the following

bin/myapp "-Dconfig.resource=prod.conf"

i.e.

docker run YOUR_DOCKER_IMAGE bin/myapp "-Dconfig.resource=prod.conf"

Pay attention to quotes on -D

Not the answer you're looking for? Browse other questions tagged or ask your own question.