Skip to content

Conversation

@danielbrutti
Copy link

Hi,

I just added information about a docker stats command and a new section for memory tweaking in case someone else had the issue I had.

Thanks,

Daniel

@danielbrutti
Copy link
Author

Hi.. I found something.. setting just the environment section on docker-compose.yml doesn't work for me

  • JAVA_OPTS="-Xmx512m -Xmx256m"

Please, do not approve this doc changes yet.. will continue working on this.

@pascalgrimaud
Copy link
Contributor

Probably a problem in syntax, with double quote

@danielbrutti
Copy link
Author

Is working, but I need to add ${JAVA_OPTS} into Dockerfile CMD line on each project to make sure the opts are added to java -jar command.

I can add this into the docs.. but I'm wondering if there is another way to make sure it uses JAVA_OPTS without modify Dockerfile.

@danielbrutti
Copy link
Author

Also.. the problem arises when executing the registry, because the memory parameters are not used when registry is in docker compose:

jhipster-registry:
        extends:
            file: jhipster-registry.yml
            service: jhipster-registry
        environment:
            - JAVA_OPTS="-Xmx512m -Xmx256m"

and jhipster-registry.yml defines the image from docker hub.

image: jhipster/jhipster-registry:v2.2.0

In this case, I don't have control on CMD line to setup ${JAVA_OPTS}

@danielbrutti
Copy link
Author

OK found it.. it works when setting up this "_JAVA_OPTIONS" environment variable... this one is used by default by the JVM. If you agree, I can modify docs using this variable instead of JAVA_OPTS

@PierreBesson
Copy link
Contributor

@danielbruti It's strange, I thought _JAVA_OPTIONS was the old name of the variable. Also it shouldn't be necessary to modify the Dockerfile to edit the env var from docker-compose. But if it happens to be the case, I will add this to the jhipster's app and registry's Dockerfile on the CMD line.
I will check everything tomorrow and come back to you.
Cc @pascalgrimmaud

@danielbrutti
Copy link
Author

danielbrutti commented Jul 4, 2016

@PierreBesson setting up _JAVA_OPTIONS in docker-compose.yml makes not necessary to add the variable in Dockerfile. CMD can remain as it is right now.

@PierreBesson
Copy link
Contributor

Ok. I guess we can go with _JAVA_OPTIONS.


## <a name="8"></a> Memory Tweaking

In order to optimize memory usage for applications running in the container, you can setup Java memory parameters on Dockerfile or docker-compose.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use backquotes around filenames? Like docker-compose.yml

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.. I also modified raw data. docker stats {% raw %}$(docker ps --format={{.Names}}){% endraw %}

@pascalgrimaud
Copy link
Contributor

strange! I always use JAVA_OPTS

@pascalgrimaud
Copy link
Contributor

pascalgrimaud commented Jul 5, 2016

@danielbrutti can you try exactly (without -> " ) this, and no additional "command" in docker-compose file

        environment:
            - JAVA_OPTS=-Xmx512m -Xmx256m

@jdubois
Copy link
Member

jdubois commented Jul 18, 2016

Is this ready to be merged or not? Doesn't look like you agree on the comments... And I also did one comment in the code that wasn't closed.

@danielbrutti
Copy link
Author

Hi, I'll finish this today, had hard weeks on work.
Sorry for the delay.

@danielbrutti
Copy link
Author

Just pushed last changes. It did not work with

- JAVA_OPTS=-Xmx512m -Xmx256m

So I left _JAVA_OPTIONS in docs too.

@jdubois
Copy link
Member

jdubois commented Jul 20, 2016

I didn't know about this _JAVA_OPTIONS setting, and found some info on this StackOverflow question.
I'm not a big fan of it, it's an undocumented option, and JAVA_OPTS should work everywhere -> I would like to remove the part on this

@danielbrutti
Copy link
Author

OK, I will remove it.. I'm not a fan of use anything different of JAVA_OPTS... but for some reason it didn't work for me. However, I'm ok with remove _JAVA_OPTIONS since is not the standard.

@pascalgrimaud
Copy link
Contributor

@danielbrutti : for your information, with my current customer, we manage to run a full stack microservices with Docker on our test environment. I didn't put any specific configuration about memory, everything works perfectly !

@danielbrutti
Copy link
Author

@pascalgrimaud yes, I read is working for everyone, just failing to me :P
That's why I'm ok with remove that option from docs.. because is more probably to be an issue from my side or OS or anything else, completely different to JHipster + Docker.

@danielbrutti
Copy link
Author

I just removed the options from docs.

@pascalgrimaud
Copy link
Contributor

@danielbrutti : your analyze helps me a lot on my current project, we had to optimize our memory on our machines. So big thanks!
You were totally right about JAVA_OPTS. It didn't work on docker-compose, but _JAVA_OPTIONS works!

I will analyze and do more tests, then I will PR an update on this documentation.

@danielbrutti
Copy link
Author

@pascalgrimaud : glad to hear that it did helped you!
We are still using _JAVA_OPTIONS, I really don't know why it does not work with JAVA_OPTS.. indeed we must use it as parameter when starting the registry with docker run too:

docker run -e "_JAVA_OPTIONS=-Xmx512m -Xmx256m" -p=8761:8761 -it jhipster/jhipster-registry:v2.2.0

Let me know if there is anything I can help.

@pascalgrimaud
Copy link
Contributor

I can see Xmx, 2 times. Maybe you miss Xms ?

@danielbrutti
Copy link
Author

@pascalgrimaud yes you are right, is Xms. Thanks!

@jgasmi
Copy link

jgasmi commented Feb 17, 2017

The JAVA_OPTS works fine for me as shown below in case this may help

environment:
- "JAVA_OPTS=-Xmx512m -Xms256m"

But when we set JAVA_OPTS we will override the spring profile variable and to fix it I have this in my docker-compose

environment:
- "JAVA_OPTS=-Dspring.profiles.active=prod -Xmx512m -Xms256m"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants