How to override the ENTRYPOINT when running a container with ACI

In a previous post How to use Azure Container Instances to host Ganache I showed you how to run Ganache in ACI but it was using all the defaults. Ganache has a lot of arguments you can pass to control how it behaves. When I started to build a CI/CD pipeline where I wanted to use Ganache in ACI as a Dev stage I wanted to override some of those defaults. In this post I will show you how to do that. 

When you use ACI to host an image you can use the --command-line argument to specify a command to override the default command line instruction baked into the container image. The trick was to first discover what the default command was. When I tried to pass "ganache -a 4 -d" the container just keep restarting. After some investigation I located the Dockerfile used to create the image. Reviewing this Dockerfile I located the ENTRYPOINT which was.

# set the entrypoint
ENTRYPOINT ["node", "/app/dist/node/cli.js"]

So I decided to pass in those two values along with -a 4 to control the number of accounts created and -d to make sure the same accounts were created each time I ran the container. This makes it easy to connect your Wallet and not have to import a new account each time. The address and private keys will be the same each time the container is running. If you don't want to use the default Mnemonic you can pass in your own as well. You can find all the command line flags in the GitHub repo. So the final command I ran was: 

az container create --resource-group TruffleSample_dev --name ganache --image trufflesuite/ganache:latest --ports 8545 --ip-address Public --output json --command-line "node /app/dist/node/cli.js -a 4 -d"

With the command-line argument you have full control on how the image is started. 

Add comment

Loading