Monday, 10 June 2024

Installing Docker on Amazon Linux 2023: A Comprehensive Guide

Installing Docker on your Amazon Linux 2023 instance can significantly streamline your development and deployment processes by containerizing your applications. While Docker installation on Amazon Linux 2 was straightforward using the amazon-linux-extras command, the 2023 version requires a different approach due to its Fedora-based architecture. Here, I’ll guide you through two effective methods to install Docker on Amazon Linux 2023, different from the commonly suggested ones.

Method 1: Using the Official Docker Repository

Instead of relying on the default package manager directly, you can install Docker from its official repository to ensure you’re getting the latest version. Here’s how you can do it:

  1. Update Your System
    Always start with an updated system to ensure compatibility and security:

    sudo dnf update -y
    
  2. Install Required Packages
    Install dnf-plugins-core, which allows you to manage your DNF repositories:

    sudo dnf install -y dnf-plugins-core
    
  3. Add the Docker Repository
    You need to manually add the Docker CE repository to your system:

    sudo dnf config-manager --add-repo https://download.docker.com
        /linux/fedora/docker-ce.repo
  1. Install Docker Engine
    Now, you can install Docker CE (Community Edition) using DNF:

    sudo dnf install -y docker-ce docker-ce-cli containerd.io
    
  2. Start and Enable Docker
    To make sure Docker runs at startup:

    sudo systemctl start docker
    sudo systemctl enable docker
    
  3. Verify Installation
    Check that Docker is installed correctly by running the hello-world image:

    sudo docker run hello-world
    

This method ensures that you are using the most recent version of Docker directly from Docker’s repositories.

Method 2: Using Convenience Script

For those who prefer a quicker setup, Docker provides a convenience script that handles the installation process:

  1. Download the Script
    Use curl to download Docker’s convenience script:

    curl -fsSL https://get.docker.com -o get-docker.sh
    
  2. Run the Installation Script
    Execute the script which automates the Docker installation:

    sudo sh get-docker.sh
    
  3. Start Docker Services
    Like the previous method, ensure Docker starts on boot:

    sudo systemctl start docker
    sudo systemctl enable docker
    
  4. Test Docker Installation
    Test your Docker setup by running:

    sudo docker run hello-world
    

This script is ideal for quick deployments and tests but may not always provide the latest version as the repository method does.

While the methods provided on community forums like Stack Overflow are efficient, using the official Docker repository or the convenience script offers more control and potentially more updated versions of Docker. These methods ensure that Docker runs optimally on your Amazon Linux 2023 system, fully leveraging its Fedora-based infrastructure. Whether you are setting up a complex development environment or a simple test application, these steps will help you successfully deploy Docker on your system.

Labels:

0 Comments:

Post a Comment

Note: only a member of this blog may post a comment.

<< Home