Search code examples
azurevirtual-machinecloud-init

How do I upgrade python3.8 to python3.9 and install docker using cloud-init on Azure VM's ubuntu?


I have followed the tutorial listed in Azure's official documentation. Automate VM Deployment

Here are the steps I followed in Azure's official tutorial.

  1. Creating a yaml file below
## Install packages on first boot
package_upgrade: true
packages:
  - docker
  - nodejs
  - python3.9
  1. Pasting the contents of cloud-config in the cloud init when I create a Ubuntu instance.

When I tried checking the Python version, it was still Python3.8 and also I could not invoke docker. When I checked the /var/log/cloud-init.log, docker has been successfully installed.

Log of less /var/log/cloud-init.log

2021-12-10 06:03:55,535 - subp.py[DEBUG]: Running command ['eatmydata', 'apt-get', '--option=Dpkg::Options::=--force-confold', '--option=Dpkg::options::=--force-unsafe-
io', '--assume-yes', '--quiet', 'install', 'docker'] with allowed return codes [0] (shell=False, capture=False)
2021-12-10 06:03:57,901 - util.py[DEBUG]: apt-install [eatmydata apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::options::=--force-unsafe-io --assume-ye
s --quiet install docker] took 2.365 seconds

Solution

    • It was still Python3.8

    How did you invoke python? Installing python3.9 won't replace the system libraries or python. So python3 will still point to python3.8, but you should be able to invoke python3.9 with python3.9.

    • I could not invoke docker

    I think you intended to install docker.io, not docker. docker in the repos is a system tray docking application.