How do I make persistent settings (sysctl.conf and others) changes to the virtual machine?

for one of my images I need some sysctl.conf changes made on the machine, currently I am using this:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty root to hop in the machine and edit the file /etc/sysctl.conf

After restarting the docker app the settings are lost, is there a way to make those changes permanent?

Out of curiosity, what setting in sysctl.conf are you looking to change?

Elasticsearch 5 requires specific settings for example (vm.max_map_count=262144)

I’m seeing the same issue when trying to run a container with elasticsearch 5 - wanted to know how you got into the docker vm to change the /etc/sysctl.conf (its asking for a login/password). Ideally it would be possible to change this setting somewhere though.

Edit: For someone else’s reference, I got past this by changing a setting in elasticsearch’s config: bootstrap.ignore_system_bootstrap_checks=true

I used screen

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

vim ~/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/etc/sysctl.conf — you can use it like this. And don’t forget to git commit it

This is what I did:
docker-machine ssh [machine_name]
sudo vi /var/lib/boot2docker/bootlocal.sh
Add the following command to bootlocal.sh: sysctl -w vm.max_map_count=262144
sudo chmod +x /var/lib/boot2docker/bootlocal.sh
exit

How can this be persisted in the latest version of Docker for Mac?