In this guide, we'll walk through installing Docker and LocalStack on CentOS Stream. LocalStack is a widely-used tool for simulating AWS services locally, helping developers test applications that interact with AWS without relying on live AWS resources. Below, you'll find a step-by-step process for setting up Docker, LocalStack, and configuring the AWS CLI to work with LocalStack. Let’s dive in!
Prerequisites
Before we start, ensure you have access to a CentOS Stream server and that you have root or sudo privileges.
Official Documentation
For detailed insights, refer to the official documentation:
- Docker Installation on CentOS
- LocalStack Getting Started Guide
- AWS CLI LocalStack Integration
- AWS CLI Commands
Step 1: Removing Old Docker Installations
First, remove any older Docker packages to avoid conflicts with the new Docker installation.
This command ensures any older versions of Docker and related packages are removed.
Step 2: Installing Docker
Install
yum-utils
yum-utils
provides theyum-config-manager
utility, which helps manage repositories.Add Docker’s Official Repository
Adding the Docker repository enables us to install Docker from official sources.Verify the Repository
Check if Docker's repository was successfully added.The output should list
docker-ce-stable
as one of the repositories.Install Docker Packages
Install Docker’s core packages, including Docker CE (Community Edition), the CLI, and additional plugins.Start Docker
Once Docker is installed, start the Docker service.Verify Docker Installation
Confirm that Docker was installed successfully.Expected output:
Step 3: Installing LocalStack
LocalStack can be downloaded as a standalone CLI, which we’ll place in /usr/local/bin
.
Download LocalStack CLI
Navigate to the Downloads directory and download the CLI tarball.Extract and Install the CLI
Extract the downloaded tarball and move it to/usr/local/bin
to make it accessible.Start LocalStack
Start LocalStack in detached mode. If you have a LocalStack authentication token, set it with theLOCALSTACK_AUTH_TOKEN
environment variable.Verify LocalStack Status
Check that LocalStack is running.You should see an output similar to this:
Step 4: Configuring the AWS CLI
To interact with LocalStack’s AWS service mock, you’ll need to set up the AWS CLI.
Install
pip
and AWS CLI
First, installpip
and then use it to install the AWS CLI.Verify AWS CLI Installation
Ensure that the AWS CLI is installed.Expected output:
Configure AWS CLI
Runaws configure
to set up a profile. For LocalStack, use placeholder values for the AWS credentials.Provide the following details:
- AWS Access Key ID:
testtest
- AWS Secret Access Key:
testtest
- Default region: ap
-southeast-3
- Default output format:
json
- AWS Access Key ID:
Modify AWS Configuration Files
To integrate AWS CLI with LocalStack, update the~/.aws/config
file:Add the following:
Similarly, update the
~/.aws/credentials
file with your credentials:Add:
Verify Configuration
Run the following command to confirm AWS CLI is set up correctly:
Step 5: Testing the LocalStack Setup
Finally, let's confirm that LocalStack is configured correctly by creating and listing an S3 bucket.
Create an S3 Bucket
List S3 Buckets
Expected output:
Confirm Bucket Region
You should see a response similar to:
Conclusion
By following these steps, you've successfully set up Docker, LocalStack, and AWS CLI on CentOS Stream, enabling you to develop and test AWS-dependent applications locally. LocalStack provides a convenient way to simulate AWS services, making it easier to work offline and avoid incurring AWS costs.
0 comments:
Post a Comment