Showing posts with label containerization. Show all posts
Showing posts with label containerization. Show all posts

Tuesday, 15 February 2022

How to Pull images from a Docker Repository and Run a container- Install jenkins using docker

 You can pull images from a Docker Repository by first looking for the image in a Docker repository eg Docker Hub, Then copy the image tag and run docker pull with the tag name

Step 1. Find the Image(Eg Jenkins)


Step 2.  Use the image name to pull the image


Here the official image name is : jenkins/jenkins:lts

Step 3. On your Docker host, Pull the image using docker pull command
docker pull jenkins/jenkins:lts

Step 4: View your image
docker images


Step 5: Run your image to get your container using the image name or image id

docker run -it -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts  Or

docker run -it -p 8080:8080 -p 50000:50000 image_id



Your Jenkins container is now running on Port 8080, You can access it by going to your Public ip:8080 on ur browser



Monday, 12 October 2020

How to Dockerise a simple Web Application / Host on a Nginx Server

 Nginx, stylized as NGINX or nginx or NginX, is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. This can be used to host web Applications.

In this lab exercise, you will learn how to create a simple web App, Create an Nginx container and deploy that App into the container. And view the results on your browser

Prerequisites: 

Install Docker


Step 1: Create the web App(HTML)

Log into your docker  machine

Create the Html file using Vi Editor

$ vi index.html

 

<!DOCTYPE html>

<html lang="en">

<head>

<title>Smashing Champions Web App!</title>

</head>

<body >

We are champions

we are champions!

</body>

</html>

Copy the Above code and paste on the editor. You can edit the body section as u please

Step 2: Create Dockerfile
open vi editor and copy the below code

$ vi Dockerfile
#FROM is the base image for which we will run our application
FROM nginx:latest

# Copy files and directories from the application
COPY index.html /usr/share/nginx/html

# Tell Docker we are going to use this port
EXPOSE 80





The above Docker file will create a base image from centos6 operating system, install nginx web server on it, then Copy the index.html file we created into "/usr/share/nginx/html" folder of the centos container. The image will be exposed in Port 80

Step 3: Create the docker image: You can tag it with -t , tag it any name you want. but we will use webapp

$ docker build -t webapp .
 
List docker images
$ docker images
You can see the base image we specified in the Dockerfile (centos), and the image created from it (webapp)

Step 4: Lets run our image
$ docker run -itd -p 8888:80 IMAGE_ID

Place your image id in place of  highlighted yellow


Step 5: Check if image is running

$ docker ps -a


Step 6: Go to your ip address:8888 (make sure u open this port in your security group




How to upgrade Maven

  java.lang.IllegalStateException I had installed maven in my ubuntu using command  apt install maven This installed maven in path /usr/shar...