Windows: How to start docker VM att system boot
I wrote a small webapp some time ago which has a system dependency which is only available for unix systems so docker was the natural choice (although i had quite some success with vagrant ..)
I am using windows for development and also running this webapp in its docker container.
So I came across the same issue, "how to start this at system boot"?
I ended up with a small batch file in my autostart directory containing something like the following lines:
docker-machine start default
docker run -d -p 8080:8080 -v //c/Users/%USERNAME%/somepath:/c/Users/%USERNAME%/somepath my/image --some.webapp.param=some-webapp-param-value
The first call starts the "default" virtual machine, although you should be able to specify a different vm there. The second call runs the "my/image" docker container, exposing port 8080 to the host system and mounting "somepath" from my user's home directory. Be sure to specify the "-d" parameter as it runs the container "in the background" (check "docker run --help")
After that my webapp can be reached at the ip address of the "default VM" (in my case that was 192.168.99.100, this may differ on your system, you can check the output when first starting this "docker quickstart terminal" as the ip address will be logged to the console.)
With that i am able to use my browser as usual, point it to "http://192.168.99.100:8080" and can work with my webapp.
Hope that helps =)
edit
with said batch file now at hand, one has 3 options:
put the batch file in your autostart directory (requires interactive user sessions, so likely not suitable for server instances..)
schedule the execution of the batch file via windows' task scheduler. there you can set "run at computer startup" as a trigger for the task. the task is run regardless of an interactive session (a logged-in user..) being available or not
use a service wrapper like NSSM to install the batch file as a windows service
Just a small addon: When you start your docker images and want them to start at boot of docker (in this case the virtualmachine running docker) you can use the --restart always option in the docker run command. Then you can remove the docker run command from your batch files. The container should start automatically after the vm started.