I can't count the number of times I formatted my computer or switched from one to another.
If like me, you're used to manage your Azure Docker VM with Docker Machine, you could end up with no solution since the Docker Machine does not provide any command to create a machine from an existing Docker engine - Github issue.
Here I propose a workaround to create a Docker Machine from scratch, using the
generic driver and a SSH key.
The machine creation will require:
- A Docker's certificates regeneration
- A Docker daemon restart which will stop running containers
You should not use this workaround on a Swarm cluster because of the regeneration of the certificates - github issue
1- Install the Azure CLI and log into your account
npm install -g azure-cli azure login
2- Set you Azure subscription ID
azure account list azure account set <subscription ID or name>
3- Find the public IP of your Azure VM
azure network public-ip list
4- Generate a SSH key and copy it to your Azure VM
ssh-keygen -t rsa -b 2048 ssh-copy-id -i ~/.ssh/id_rsa.pub email@example.com
5- Create the Machine
docker-machine create \ --driver generic \ --generic-ip-address=188.8.131.52 \ --generic-ssh-key ~/.ssh/id_rsa \ --generic-ssh-user emyann \ blog docker-machine regenerate-certs blog
Enjoy you Azure Docker Machine !
This workaround has some limitations, but at the of the day, I just had to restart my containers and now I'm able to easily manage my Azure Docker VM from my local computer!
See you on the next posts!