Azure part of story
- First create one Azure account, I am using a student account
- Create a basic instance (Ubuntu image works for most cases) with 1 vCPU and 1 GiB RAM, or according to your needs
- Download the private key and SSH into the instance
- Update the packages
- Install docker (following this guide)
Let’s move on to the local machine setup
Local machine setup
SSH Keys Setup
- We need to install docker here as well
- Add ssh key (downloaded from Azure portal) to OpenSSH Auth agent
eval 'ssh-agent'
ssh-add <path-to-pem-file>/<file-name>.pem
- (or) Add
AddKeysToAgent yes
to ~/.ssh/config file to automatically do that for you
echo "AddKeysToAgent yes" >> ~/.ssh/config
Docker Context Setup
- Create a new docker context to talk to the docker in Azure instance with command
docker context create azure-box --docker "host=ssh://azureuser@<public-ip-of-instance>"
- See all available contexts using
docker context ls
- Switching to Azure docker is done using command
docker context use azure-box
and back to the local docker usingdocker context use default
- Now when we issue commands to docker as usual
docker ps
, it is directly communicating to the docker running in the Azure instance
Note: ‘azure-box’ is just a name, can be replaced with anything of your choice