Prevent swap in docker container

How can I prevent ElasticSearch 1.7 from swapping when running inside a docker container?

I am running the container with the -memory-swap=-1 flag, and still seeing around 500 MB of swapping.
Is this normal?

Also tried to add bootstrap.mlockall: true to the elasticsearch.yml file, but then got the message:
Unable to lock JVM memory (ENOMEM). This can result in part of the JVM being swapped out. Increase RLIMIT_MEMLOCK (ulimit).

Is there any documented way to achieve this?

Thanks. should help.

There are 3 ways to achieve this, two of them require a system-wide change which I am currently not able to do.
Is there any way to do this from within a Docker container without affecting the whole server, and succeed?

I was using the wrong docker run flag.
To prevent swapping, you should use something like --memory-swappiness=0 --memory 40G --memory-swap 40G.
By stating the memory is X and memory+swap is X, you prevent swapping.