Search code examples
azuredockerazure-virtual-machinedocker-machine

Docker-machine: Update the azure driver configuration


I have an issue with a docker machine I am running in the Azure cloud. I created the machine using the default size, which is Standard_A2 but I want to upgrade the machine.

I tried to manually change the size to Standard_A4 through the Azure Web Portal, which seemed to work fine since the virtual machine restarted and in the overview section it says:

Size
Standard A4 (8 vcpus, 14 GB memory)

However, when running the command docker-machine inspect <machine-name> the configuration still shows that the size of the machine is Standard_A2. See below:

{
    "ConfigVersion": 3,
    "Driver": {
        ...

        "ResourceGroup": "docker-machine",
        "DockerPort": 2376,
        "Location": "westeurope",
        "Size": "Standard_A2",

        ...
    },
    ...
}

I know that I can remove the whole machine and create a new one with a different default size using the --azure-size option, however, I think it is weird if there is no way to upgrade a machine that is already running.

Any idea of how this could be achieved? I could not find anything in the documentation...


Solution

  • For now, we can't use docker-machine command line to update an existing virtual machine.

    Here is the docker-machine for Azure go file, it says an existing virtual machine cannot be updated.

    In your scenario, as a workaround, after you resize your Azure VM, we can change the config.json from Standard_A2 to Standard_A4.

    We can find the config.json here:

    /root/.docker/machine/machines/<machine-name>
    

    After we change that json file, run docker-machine inspect myvms we will get this new result:

    [root@jasoncli@jasonye myvms]# docker-machine inspect myvms
    {
        "ConfigVersion": 3,
        "Driver": {
            "IPAddress": "",
            "MachineName": "myvms",
            "SSHUser": "azureuser",
            "SSHPort": 22,
            "SSHKeyPath": "/root/.docker/machine/machines/myvms/id_rsa",
            "StorePath": "/root/.docker/machine",
            "SwarmMaster": false,
            "SwarmHost": "tcp://0.0.0.0:3376",
            "SwarmDiscovery": "",
            "ClientID": "",
            "ClientSecret": "",
            "Environment": "AzurePublicCloud",
            "SubscriptionID": "xxxx1ed3-xxxx-44fb-b5ba-xxxxa07xxxx",
            "ResourceGroup": "docker-machine",
            "DockerPort": 2376,
            "Location": "westus",
            "Size": "Standard_A4",
    

    Hope this helps.