Jack Wallen helps you take your primary steps with Amazon Linux as a deployable container image.
Image: Alexey Novikov/Adobe Stock Did you understand that Amazon Linux is available to use and can be deployed even beyond the AWS cloud facilities? That’s right. The image is main and preserved by the Amazon Linux Team.
Amazon Linux has been created to be utilized for stable, safe and secure, and high-performance environments for applications that are deployed on Amazon EC2. The circulation consists of all the software application you need to incorporate with AWS, such as launch config tools and lots of AWS libraries.
SEE: Hiring package: Back-end Designer (TechRepublic Premium)
But Amazon Linux isn’t limited to deploying on AWS, as it is supported on any platform that supports Docker. I want to walk you through your initial steps utilizing Amazon Linux as an image you can utilize for container release.
What you’ll require to use Amazon Linux
The only thing you’ll require to utilize Amazon Linux is a fully-functioning Docker environment. I’ll be demonstrating on Ubuntu Server 22.04 and will show you how to first get the current variation of Docker set up.
How to set up Docker
The very first thing to do is add the needed repository. Prior to that, nevertheless, we should initially, include the GPG secret with the command:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg|sudo gpg– dearmor -o/ usr/share/keyrings/ docker-archive-keyring. gpg
Next, include the repository:
echo “deborah [arch=amd64 signed-by=/ usr/share/keyrings/ docker-archive-keyring. gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”|sudo tee/ etc/apt/sources. list.d/ docker.list >/ dev/null
Prior to we can install Docker, let’s install a couple of dependencies with the command:
sudo apt-get set up apt-transport-https ca-certificates curl gnupg lsb-release -y
Finally, we can install the latest version of the Docker engine:
sudo apt-get upgrade
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
To end up things up, include your user to the docker group with:
sudo usermod -aG docker $USER
Log out and log back in so the changes will work.
How to pull the official Amazon Linux image
Must-read developer coverage
The very first thing we must do is pull the main Amazon Linux image with the command:
docker pull amazonlinux
When the image has been pulled, you can view it with:
You must see something like this:
amazonlinux most current 3bc3c7c96b1d 3 weeks ago 164MB
How to deploy a container from the Amazon Linux image
We’re now going to deploy the container image in such a way that we’ll end up within the container at the bash timely. This is accomplished with the command:
docker run -it amazonlinux: most current/ bin/bash
How to install software application on Amazon Linux
One of the first things you might want to do is upgrade the running OS with the command:
Once the upgrade finishes, let’s install some software. We’ll install the nano full-screen editor and Python with the command:
yum install nano python3 -y
How to commit your modifications to the container
When the software application is set up, we’ll dedicate the modifications we just made to the container. Initially, leave the container with the command:
Next, find the container ID with the command:
docker ps -a
The ID will be a random string of characters, such as ffb079663b4b.
To dedicate the changes, the command will be:
docker dedicate ID NAME
Where ID is the container ID and NAME is a new name for the container. For example, the command may be:
docker devote ffb079663b4b amazonlinux-python
After the dedicate completes, you should now see a new image noted with the command:
The brand-new image must be called amazonlinux-template and will consist of the added software. You can then deploy a brand-new container from that image with a command like this:
docker run -it amazonlinux-python/ bin/bash
You’ll then find yourself within a brand-new container, based upon the Amazon Linux image you produced which contains both the nano text editor and the Python programs language. You are now all set to start developing Python apps within that containerized environment.
Sign up for TechRepublic’s How To Make Tech Work on YouTube for all the current tech advice for business pros from Jack Wallen.