I ran into the same error message when attempting to create an Amazon Linux 2 instance using the AWS CDK. The CDK currently defaults to Amazon Linux instead of Amazon Linux 2. When you accidentally use an Amazon Linux AMI from 2018, surprise surprise, all sorts of facilities are not available. I posted an easy way to check your version in another answer.

In CDK (and Cloud Formation) make sure to declare your intended generation in your AmazonLinuxImage properties

generation: AmazonLinuxGeneration.AMAZON_LINUX_2
Answer from Derek Bennett on serverfault.com
🌐
AWS re:Post
repost.aws › knowledge-center › ec2-install-extras-library-software
Install software from the Extras Library on an AL2 EC2 instance | AWS re:Post
June 18, 2025 - Just trying to install Java 11 from amazon-linux-extras, with out luck. ... [ec2-user@ip-172-31-99-999 ~]$ sudo yum install -y amazon-linux-extras Last metadata expiration check: 0:09:51 ago on Tue Apr 4 14:04:54 2023.
🌐
Amazon Web Services
aws.amazon.com › compute › amazon linux 2 › faqs
Amazon Linux 2 FAQs
1 week ago - The packages associated with each topic are consumed with the well-known yum installation process. Available packages can be listed with the amazon-linux-extras command in the Amazon Linux 2 shell. Packages from extras can be installed with the “sudo amazon-linux-extras install ” command.
Discussions

node.js - sudo: amazon-linux-extras: command not found - Stack Overflow
I found another way to install nginx1. I just solved the problem ... SO is a programming Q&A platform and this question is not about programming. What topics can I ask about here? Please delete this. ... Check the Amazon image version of your EC2 instance. ... If it is Amazon Linux 2023, it does not have extras. However, most of the packages are already included in the distro. You can run sudo yum ... More on stackoverflow.com
🌐 stackoverflow.com
ansible - amazon-linux-extras enable vs install - Stack Overflow
Check that you have permissions to install. I added a version check - ansible --version || exit 1 and it passes for amazon-linux-extras enable ansible2 which means that it too installs it (but somehow manages not to fail). ... amazon-linux-extras install ansible2 enables the yum repositories ... More on stackoverflow.com
🌐 stackoverflow.com
Docker installation gives an error on Amazon Linux 2 when following the official documentation. Any ideas how to fix this?
Why not try the provided script instead? curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh Does this fail too? Or download the .rpm https://download.docker.com/linux/centos/ and install that? https://download.docker.com/linux/centos/2/x86_64/stable/repodata/repomd.xml : For whatever reason the repo is trying to access the folder for version "2", which doesnt exist as you can see here . [docker-ce-stable] name=Docker CE Stable - $basearch baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stable enabled=1 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg Probably because your OS is reporting version "2" as the OS version, but the Docker repo expects a version number for CentOS such as "9" and "2" is simply not supported at all. Maybe you can manually add the correct URL to your package manager. Look at documentation for CentOS/AL2. A 5 second Google search gives this for example: https://www.cyberciti.biz/faq/how-to-install-docker-on-amazon-linux-2/ More on reddit.com
🌐 r/docker
7
0
October 12, 2024
ssh - Error: sudo: amazon-linux-extras: command not found - Stack Overflow
System Information: Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1045-aws x86_64) Problem: Trying to run sudo amazon-linux-extras install epel -y and sudo yum install -y chromium Because i need it for my Di... More on stackoverflow.com
🌐 stackoverflow.com
🌐
AWS
docs.aws.amazon.com › amazon linux › user guide › al2 extras library
AL2 Extras Library - Amazon Linux 2
This command does not remove packages that were installed as dependencies of the Extra. To disable a topic and make the packages inaccessible to the yum package manager, use the following command. [ec2-user ~]$ sudo amazon-linux-extras disable topic · This command is intended for advanced users. Improper usage of this command could cause package compatibility conflicts. ... Thanks for letting us know we're doing a good job! If you...
🌐
LinuxVox
linuxvox.com › blog › amazonlinuxextras-command-not-found
Troubleshooting amazonlinux-extras command not found — linuxvox.com
If the package is not installed, you can install it using the following command: sudo yum install -y amazon-linux-extras · To check the PATH environment variable, run the following command: echo $PATH ·
Find elsewhere
🌐
Super User
superuser.com › questions › 1487748 › unable-to-find-or-install-amazon-linux-extras
Unable to find or install amazon-linux-extras - Super User
[arjun@ip-172-31-32-27 ~]$ which ...sr/sbin:/home/arjun/.local/bin:/home/arjun/bin) [arjun@ip-172-31-32-27 ~]$ sudo yum -y install amazon-linux-extras [sudo] password for arjun: Loaded plugins: extras_suggestions, langpacks, ...
🌐
Amazon Web Services
docs.aws.amazon.com › amazon linux › user guide › al2 on amazon ec2 › configure al2 instances › manage software on your al2 instance › add repositories on an al2 instance
Add repositories on an AL2 instance - Amazon Linux 2
January 13, 2023 - After you install a repository, you must enable it as described in the next procedure. Use the yum-config-manager command with the --enable repository flag. The following command enables the Extra Packages for Enterprise Linux (EPEL) repository from the Fedora project. By default, this repository is present in /etc/yum.repos.d on Amazon Linux AMI instances, but it is not enabled. [ec2-user ~]$ sudo ...
🌐
Bobcares
bobcares.com › blog › install-a-software-package-from-the-extras-library-on-ec2
Install a software package from the Extras Library on EC2
August 15, 2021 - For installing a software package from the Extras library, first, we need to install the amazon-linux-extras repository on the instance. Then we need to list the available packages and enable the desired ones. After enabling, then using yum we can install the software packages.
🌐
Medium
mavisec.medium.com › install-a-software-package-from-the-extras-library-on-an-ec2-instance-f0ecdb6b94b2
Install a software package from the Extras Library on an EC2 instance - mavisec - Medium
November 21, 2021 - To install a software package from the Extras Library, first confirm that the amazon-linux-extras repository is installed on your instance. Then, list the available software packages, enable the one you’re looking for, and then install the package using yum.
🌐
Educative
educative.io › answers › how-to-get-started-with-aws-ec2
How to get started with AWS EC2
You can confirm this by running the following command: amazon-linux-extras list | grep nginx · To install it, run: sudo amazon-linux-extras install nginx1 · We can verify that it was installed successfully by running: nginx -v · Let’s start ...
🌐
Reddit
reddit.com › r/docker › docker installation gives an error on amazon linux 2 when following the official documentation. any ideas how to fix this?
r/docker on Reddit: Docker installation gives an error on Amazon Linux 2 when following the official documentation. Any ideas how to fix this?
October 12, 2024 -
  • I want to install docker 27.2.0 on amazon linux 2

  • I followed the guide as mentioned here

It gives me an error

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

I am immediately running into this error

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
https://download.docker.com/linux/centos/2/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.


 One of the configured repositories failed (Docker CE Stable - x86_64),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=docker-ce-stable ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable docker-ce-stable
        or
            subscription-manager repos --disable=docker-ce-stable

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=docker-ce-stable.skip_if_unavailable=true

failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://download.docker.com/linux/centos/2/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

Anyone knows how to get docker running inside Amazon Linux 2 EC2 instance?

Just to clarify i am trying to run this inside EC2 user data script in case that matters

🌐
Stack Overflow
stackoverflow.com › questions › 68828553 › error-sudo-amazon-linux-extras-command-not-found
ssh - Error: sudo: amazon-linux-extras: command not found - Stack Overflow
Check Package Installation: Confirm whether the package providing amazon-linux-extras is installed correctly. You can use the package manager to check if it's installed: sudo yum list installed | grep amazon-linux-extras
🌐
Stack Overflow
stackoverflow.com › questions › 62335429 › how-to-install-amazon-linux-extras-on-ec2-ubuntu-18-0
how to install amazon-linux-extras on EC2 Ubuntu 18.0 - Stack Overflow
TL;DR The amazon-linux-extras command is a distribution specific feature of Amazon Linux 2, it's not available with Ubuntu AMIs. If you need install specific tools for the local VM's OS (or you're building a Ubuntu container), you'll need to ...