Install Docker Ec2 Linux

/ Comments off

The first step, however, is to install Docker Compose. If you're running Windows or Mac, Docker Compose is already installed as it comes in the Docker Toolbox. Linux users can easily get their hands on Docker Compose by following the instructions on the docs. Since Compose is written in Python, you can also simply do pip install docker-compose.

Oct 02, 2021 Install Docker Compose Ec2 Linux Ubuntu; Install Docker Compose Ec2 Linux Command; Key Features and Capabilities. UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using. 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, #yum install docker -y.

This tutorial explains, how to install docker on EC2 Instance. Before starting, let’s have some brief knowledge about Docker.

Docker is a platform that combines applications and its dependencies in the form of packages, called container. We can run multiple containers on a single Operating System. Containers are not Virtual Machines. Virtual Machines requires Operating System to run applications, but containers do not. As containers don’t need an Operating System, it takes very little time to start and hence it is very faster than Virtual Machines.

The Amazon Linux AMI-based Docker platform can be used to deploy a Docker image (described in a Dockerfile or Dockerrun.aws.json definition) and source code to EC2 instances that are running in an Elastic Beanstalk environment. This Docker platform runs only one container for each instance. Grras Solutions is one of the best CCNA, Red Hat Linux ( RHCSA & RHCE ) and AWS cloud Certification and training course provider in Jaipur, Ahmedabad, Indore and Delhi.100% Job Placement.

Also Learn: How to install Ansible on Amazon Linux(EC2 )

and Launching Amazon Linux EC2 Instance

Install Docker Aws Linux Command

Let’s Install Docker on EC2 Instance

In this tutorial, we will use Amazon Linux to install docker. Amazon Linux/Amazon Linux2 is the Linux Operating System used in EC2 Instance.

Step 1– Log to Linux EC2 Instance and update it.

$ sudo yum update -y

Step 2– Install docker using Yum command

$ sudo yum install docker -y

Step 3– Start Docker Service

$ Service docker start

Step 4– Check docker Version.

$ docker -v

Basic Configuration (Creating Docker File / Running Docker Image)

After you install docker on ec2 , let’s have some basic setup for Docker.

Install Docker Ec2 Linux

Step 1 – Create a docker file

Dockerfile is a text file where we write instructions to build an image.

Create a folder name Images on the Amazon Linux box.

Install docker ec2 linux server

$ mkdir images

Move to folder images

$ cd images

Create a file name Dockerfile inside images folder

$ nano Dockerfile

Put the content in the following way inside the Dockerfile.

FROM Ubuntu ( It will use the Official image Ubuntu to build your image)

MAINTAINER chandan <[email protected]>

( It sets the Author field of the generated image)

RUN apt-get update ( It will update the image at the time of Build)

CMD [ “echo”, ” Hello World ……….! “] ( It will run echo command when we run the docker container image)

Install docker on aws ec2 linux instance

Install Docker On Ec2 Amazon Linux 2

Please also readHow to install docker on ec2 Instance(Windows)

You may also likeInstall Docker on Ubuntu using Script

Step 2– Run the docker build command to build the image.

Install docker ec2 linux free

$ docker build .

Note : ( . command is used when you are inside images folder where Dockerfile is present, alternatively you can put the docker file absolute path like /home/ec2-user/images/Dockerfile)

You can run the following command as well to Name and tag your Image. Here myimage is the Name and 01 is Tag of the image.

$ docker build -t myimage:01 .

Step 3– See the Docker Images after build

$ docker images

Install Nvidia-docker Amazon Linux

Step 4 – Run the docker image

$ docker run 07deaa33585e

Here 07deaa33585e is the IMAGE ID that can be seen in docker images command.

You can see here, it executed the echo command as soon as we run the docker image. In the same way, we can run any script, commands or any application by running a docker image.

Click to tweet this tip !

I hope you enjoyed this tutorial and learned to install docker on ec2 instance (Amazon Linux). If you think this is really helpful, please do share this with others as well. Please also share your valuable feedback, comment or any query in the comment box. I will really happy to resolve your all queries anytime.

Thank You

If you think we helped you or just want to support us, please consider these:-

Install Docker Aws Linux Centos

Install Docker Aws Linux

Connect to us: FacebookTwitter