Saturday, June 8, 2024

Docker installation On Ubuntu 20.04

The journey of a thousand containers begins with a single step: installing Docker

Connect to ubuntu ec2 instance

Update the package list and install necessary packages:

sudo apt-get update

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common


Install Docker

sudo apt-get update

sudo apt-get install docker.io -y

sudo usermod -aG docker $USER   #my case is ubuntu

newgrp docker

sudo chmod 777 /var/run/docker.sock


Verify Docker Installation

docker --version


DockerHub - How to create docker images from Container

Run my first container

On Docker Hub, there are two kinds of images - official and unofficialOfficial images are trusted and optimized. They have clear documentation, promote best practices, and are designed for the most common use cases. On the other hand, an unofficial image is any image that is created by a user. Docker Hub follows some standards so that both can easily be identified. Official images contain only the <image_name> as its image name but unofficial images have the syntax as <username>/<image_name>. Also, the official image has official written in the listing as shown in the below screenshot.

Official Image of Ubuntu


Unofficial Image by User ubuntuz


Downloading Image from Docker Hub

Search the Docker Hub for Images

We could also look up and find images on Docker Hub by either using the search bar on the website or using the below command: 

$ docker search <image_name>


Let us search for an image with the name of Jenkins:

Pull the Jenkins Docker Image

You can pull the official Jenkins Docker image from Docker Hub. Open your command line or terminal and run the following command:





Configure the Docker Container for Jenkins

Once the image is pulled, you can create a Docker container. The following command creates a Jenkins container with the necessary settings:

docker run -d -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home --name jenkins jenkins/jenkins:lts

 

Access Jenkins

After running the container, Jenkins will take a minute to start up. Once it's ready, you can access Jenkins by opening a web browser and navigating to http://localhost:8080.

The first time you access Jenkins, you will need to unlock it. Retrieve the initial admin password by running:

 







 

 







No comments:

Post a Comment

  PROMETHEUS AND GRAFANA A robust performance monitoring and alerting stack is crucial to service reliability. Cloud Native Computing Foun...