Hello everyone
I am trying to set up a container for my Java application using lsiobase/alpine:3.12 and openjdk8-jre. Said application supports two arguments, -cgen
and -cont
.
-cont
is supposed to be used when the application is run in a docker environment. The service is started via the run script:
#!/usr/bin/with-contenv bash
cd /app/serverpackcreator
exec s6-setuidgid abc java -jar /app/serverpackcreator/serverpackcreator.jar -$START
Where START is set in the docker-compose as START=cont
I've tested whether that is passed correctly by setting START to cgen
and the application starts into the corresponding mode, however, when it is set to cont
it doesn't start to the corresponding mode.
When I run serverpackcreator.jar -cont
in my Windows CLI or a Linux CLI in a VM or on my VPS, it works fine, but as soon as I try to run it with the s6 overlay in a container, the argument is...ignored?
I've tried changing the argument to different ones, for example -docker
and -dock
but no dice. I'm slowly starting to pull out my hair here, so I was hoping anyone would have an idea as to what I am doing wrong here.
Is there something I need to keep in mind when using s6 and command line arguments which I am missing?
The check for the argument in my Java application is this:
if (Arrays.asList(args).contains(Reference.CONFIG_GEN_ARGUMENT) || (!Reference.oldConfigFile.exists() && !Reference.configFile.exists())){
CLISetup.setup();
} else if (Arrays.asList(args).contains(Reference.DOCKER_ENV_ARGUMENT)) {
appLogger.info(String.format("You started ServerPackCreator with the \"%s\" argument. Adding prefix \"/data/\" to modpackDir...", Reference.DOCKER_ENV_ARGUMENT));
Reference.dockerEnv = true;
} else { Reference.dockerEnv = false; }
and as I said, it works fine for -cgen, but not for -cont, -dock or -docker, in the container. Locally, non-docker, it all works as expected...
Okay, having looked at this, first thing I would do is log the contents of
args
in your app in a way you can see when you run the container. Then you'll know if it's the way you're invoking the app (unlikely given what you've said) or the app logic quoted here. You could also try adding anenv
orenv | sort
line to the run script, so that you see if the script has the env var you're expecting (i.e. is it getting passed in from docker-compose as you're expecting).