Install Aws Cli In Docker Container

  1. Install Aws Cli Inside Docker Container
  2. Install Aws Cli In Jenkins Docker Container
  3. Install Aws Cli In Docker Container

In this article we will perform Docker installation as well as we will configure “Container” and “Images” with easy steps on AWS Ec2 instance. We are using Amazon Linux distribution and assuming that you have already created your AWS account if not you can refer this article Create AWS free tier account. Once you logged into AWS account and connected to your AWS Ec2 instance you can follow below steps to perform Docker installations.

The following prerequisites are needed for the container deployment with this AWS Copilot tutorial: Install Docker; Install AWS Copilot CLI; Set up an AWS Account; Deploy your preferred VPC (including subnets) or use the template I created for this tutorial. Configure the aws cli. Set the aws credentials in the ubuntu user. Run: aws configure. ⚠️ This credentials are only available to the ubuntu user and not by jenkins, that is why we need to use the next aws plugin and set credentials for jenkins. Credentials location: /.aws (Home directory) Home directory in this case: /home/ubuntu/.aws.

1.Get ready your Ec2 Instance

When you are logged into your AWS Ec2 instance you have to update all the packages, before that you have to switch to root user account using command sudo su and then you can use below command;

  • This allows the AWS SDK used by application code to access a local mock container as “AWS metadata API” and retrieve credentials from your own local.aws/credentials config file. Install the Docker Compose CLI on Linux. The Docker Compose CLI adds support for running and managing containers on ECS. Install Prerequisites. Docker 19.03 or later.
  • You also need to provide AWS credentials to the container, so that the CLI can do its job. I prefer managing access keys as environment variables, and it’s easy to tell Docker to export your current variables inside a container, so that’s the approach I show here.

Install Aws Cli Inside Docker Container

2. Install Docker

Once you used above command it will update packages on ec2 instance or it will give message “no packages marked for update” it means your ec2 instance already have all the latest packages installed.

Now, you can install Docker using below command,

This command will installed Docker softwares and its dependencies.

3.Verify Docker Installation


4.Start Docker

Now, you can check status and start Docker service using below commands;

You can find all the status of the Docker using command “docker info” It will provide you all the information.

Install Aws Cli In Docker Container

5.Check Available Docker Images/Containers

Now, you can check available Docker Images and Containers with help of below commands, if you don’t know about what is Docker Image, what is Docker Container, what is Docker Client and what is Docker Hub then you go through this Docker-Containers Lets understand it with simplest way article to easily understand all the terms.

“docker images” command used to check available images on your Docker server or Docker engine

“docker ps” (ps stand for process status) command is used to check all running containers and “docker ps -a” (-a stands for all) command is used to check all running as well as stopped containers.

6.Download Docker Images

Now, you required to create and download Docker images of various distributions for that you can use docker file or you can directly download Docker images from hub.docker.com.

You can also download Docker images using below command,

Now, in below example I am installing “ubuntu” image. So, as you can see as soon as we run above command Docker search ubuntu image in local machine first and in case it not found Docker can pull image from hub.docker.com.

7.Verify Installed Images/Containers

As soon as you run above “docker run -it ubuntu /bin/bash” command your Docker container will be ready and you will be reached within that (ubuntu) Container. You can verify it using below command;

Now, you can enter exit command and you will be exit from the container and your container will also stopped. You can now use below command to check available images on your Docker server/engine.

This time you will see “ubuntu” image which we have installed.

Install Aws Cli In Jenkins Docker Container


Now, check available containers with below command;

You can find now, one Container available which is in stopped state.

Install Aws Cli In Docker Container

8. Docker Commands Best Practices

Command to search docker images that available on docker hub

Command to start container; you can use container name or id to start container.

Command to go to inside the running containers; use container name or id to go inside running containers

Hope this article helpful you. Please like, share and subscribe to https://devopsarticle.com


Related Article:

Most Viewed Posts