Search code examples
azuredockerazure-container-instanceseos

Running docker commands in an Azure container


I've been struggling far longer than I should have on this and I'm sure I must be doing something the hard way.

Basically all I want to do is run a docker image in azure (the eos-dev blockchain image). I've gone through and created the container registry, enabled admin control and created the container using:

az container create --resource-group docker --name eosnode --image xxx.azurecr.io/eos-dev --cpu 1 --memory 14 --ip-address public --ports 80 7777 5555 --registry-password "zzz"

Now if this was a local docker instance id simply be able to run:

docker network create testnetwork

And I would get this back:

77af2f92d66895bbf71490b33d775a116d6d8d7be0cbd0a2b3d18ce7336cf611

Now, I'm attempting to do it on the remote azure container like this:

az container exec -g docker --name eosnode --container-name eosnode --exec-command "docker network create testnetwork"

But it returns nothing and I have no idea if it even did anything. What am I missing here?


Solution

  • As you say, you just want to run a docker image in Azure. And I see you create the container instance with the command:

    az container create --resource-group docker --name eosnode --image xxx.azurecr.io/eos-dev --cpu 1 --memory 14 --ip-address public --ports 80 7777 5555 --registry-password "zzz"
    

    For this step, the container instance is created in Azure. And you can get the instance information through the command az container show or get logs of the instance with the command az container log.

    Also, you can execute the command inside the container instance using the command like this:

    az container exec -g resrouceGroup -n instanceName "bash command"
    

    But if you want to run the command docker network create testnetwork inside the container instance, you should install the docker inside the image which you create the container instance from.