I use this script to install docker on my Azure Debian 11 VM:
** Updating package lists...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 700 (apt-get)
E: Unable to lock directory /var/lib/apt/lists/
** Installing dependencies...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
Package gnupg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'gnupg' has no installation candidate
E: Unable to locate package software-properties-common
** Adding Docker GPG key...
E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
(23) Failed writing body
** Adding Docker repository...
sudo: add-apt-repository: command not found
** Updating package lists again...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 700 (apt-get)
E: Unable to lock directory /var/lib/apt/lists/
** Installing Docker...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package docker-ce
** Docker installation complete!
However, if I run this script manually (1 line at a time), in my Azure Debian 11 VM it works, however when I use it as Custom Data so it would execute on VM initialization, it gives errors, here’s the cloud-init-output.log:
** Updating package lists...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 700 (apt-get)
E: Unable to lock directory /var/lib/apt/lists/
** Installing dependencies...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
Package gnupg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'gnupg' has no installation candidate
E: Unable to locate package software-properties-common
** Adding Docker GPG key...
E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
(23) Failed writing body
** Adding Docker repository...
sudo: add-apt-repository: command not found
** Updating package lists again...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 700 (apt-get)
E: Unable to lock directory /var/lib/apt/lists/
** Installing Docker...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package docker-ce
** Docker installation complete!