Create Jenkin Web Server with Jenkin Image in the Container By Using Port Expose
Dear Readers,
In this article,we will see Create Jenkin Web Server with Jenkin Image in the Container (Port Expose).
Steps to Follow
- Search the Jenkins image from online Docker Registry (Docker Hub).
- Create a Demonized Container “ktexperts-jenkins” with image “jenkins” and port mapping 8080:8080.
- Verify the container.
- Verify content of container “ktexperts-jenkins”.
- Add the port 8080 in Security Group of Docker Instance.
- Verify content of container “ktexperts-jenkins”.
To see the list of all images in your machine
1 2 3 |
[root@ip-172-31-4-99 ec2-user]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 549b9b86cb8d 3 weeks ago 64.2MB |
To see the list of running containers
1 2 3 |
[root@ip-172-31-4-99 ec2-user]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c47768516a3e ubuntu "/bin/bash" 25 minutes ago Up 25 minutes 0.0.0.0:80->80/tcp ktexperts-webserver |
To see the list of all the containers
1 2 3 |
[root@ip-172-31-4-99 ec2-user]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c47768516a3e ubuntu "/bin/bash" 25 minutes ago Up 25 minutes 0.0.0.0:80->80/tcp ktexperts-webserver |
1. Search the Jenkins image from online Docker Registry (Docker Hub)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
[root@ip-172-31-4-99 ec2-user]# docker search jenkins NAME DESCRIPTION STARS OFFICIAL AUTOMATED jenkins Official Jenkins Docker image 4595 [OK] jenkins/jenkins The leading open source automation server 1852 jenkinsci/blueocean https://jenkins.io/projects/blueocean 476 jenkinsci/jenkins Jenkins Continuous Integration and Delivery … 376 jenkinsci/jnlp-slave A Jenkins slave using JNLP to establish conn… 117 [OK] jenkins/jnlp-slave a Jenkins agent (FKA "slave") using JNLP to … 109 [OK] jenkinsci/slave Base Jenkins slave docker image 62 [OK] jenkinsci/ssh-slave A Jenkins SSH Slave docker image 40 [OK] jenkins/slave base image for a Jenkins Agent, which includ… 38 [OK] cloudbees/jenkins-enterprise CloudBees Jenkins Enterprise (Rolling releas… 34 [OK] h1kkan/jenkins-docker Extended Jenkins docker image, bundled wi… 27 jenkins/ssh-slave A Jenkins slave using SSH to establish conne… 26 [OK] xmartlabs/jenkins-android Jenkins image for Android development. 26 [OK] bitnami/jenkins Bitnami Docker Image for Jenkins 21 [OK] openshift/jenkins-2-centos7 A Centos7 based Jenkins v2.x image for use w… 21 cloudbees/jenkins-operations-center CloudBees Jenkins Operation Center (Rolling … 14 [OK] vfarcic/jenkins-swarm-agent Jenkins agent based on the Swarm plugin 8 [OK] openshift/jenkins-slave-base-centos7 A Jenkins slave base image. DEPRECATED: see … 7 publicisworldwide/jenkins-slave Jenkins Slave based on Oracle Linux 5 [OK] openshift/jenkins-1-centos7 DEPRECATED: A Centos7 based Jenkins v1.x ima… 4 trion/jenkins-docker-client Jenkins CI server with docker client 4 [OK] ansibleplaybookbundle/jenkins-apb An APB which deploys Jenkins CI 1 [OK] jameseckersall/jenkins docker-jenkins (based on openshift jenkins 2… 0 [OK] mashape/jenkins Just a jenkins image with the AWS cli added … 0 [OK] amazeeio/jenkins-slave A jenkins slave that connects to a master vi… 0 [OK] |
2. Create a Demonized Container “ktexperts-jenkins” with image “jenkins” and port mapping 8080:8080
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[root@ip-172-31-4-99 ec2-user]# docker run -td --name ktexperts-jenkins -p 8080:8080 jenkins Unable to find image 'jenkins:latest' locally latest: Pulling from library/jenkins 55cbf04beb70: Pull complete 1607093a898c: Pull complete 9a8ea045c926: Pull complete d4eee24d4dac: Pull complete c58988e753d7: Pull complete 794a04897db9: Pull complete 70fcfa476f73: Pull complete 0539c80a02be: Pull complete 54fefc6dcf80: Pull complete 911bc90e47a8: Pull complete 38430d93efed: Pull complete 7e46ccda148a: Pull complete c0cbcb5ac747: Pull complete 35ade7a86a8e: Pull complete aa433a6a56b1: Pull complete 841c1dd38d62: Pull complete b865dcb08714: Pull complete 5a3779030005: Pull complete 12b47c68955c: Pull complete 1322ea3e7bfd: Pull complete Digest: sha256:eeb4850eb65f2d92500e421b430ed1ec58a7ac909e91f518926e02473904f668 Status: Downloaded newer image for jenkins:latest a726e3e291e9422cf43419c9d5ce1ee42ad467c54a59d48b6a565644509f4c51 |
3. Verify the container
To see the list of running containers
1 2 3 4 |
[root@ip-172-31-4-99 ec2-user]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a726e3e291e9 jenkins "/bin/tini -- /usr/l…" About a minute ago Up About a minute 0.0.0.0:8080->8080/tcp, 50000/tcp ktexperts-jenkins c47768516a3e ubuntu "/bin/bash" 30 minutes ago Up 30 minutes 0.0.0.0:80->80/tcp ktexperts-webserver |
4. Verify content of container “ktexperts-jenkins”
Generally container won’t have any IP that’s why we expose the ports in both sides then give Docker Public IPV4 to users.
They can access container webserver through docker.
Copy Public IPV4 of the Docker
Search IPV4 Public IP along with port 8080 (13.232.62.198:8080) of Docker in browser
we unable to see content of the container “ktexperts-jenkins” because of we didn’t add the port in SG of base machine (docker instance)
We need to add the port 8080 in SG of Docker Instance.
5. Add the port 8080 in Security Group of Docker Instance
Select Docker instance and click on Security Group “Docker-SG”.
Go to Inbound and click on Edit.
Click on Add Rule.
Add port 8080 and click on save.
6. Verify content of container “ktexperts-jenkins”
Refresh,IPV4 Public IP along with port 8080 (13.232.62.198:8080) of Docker in browser.
we can able to see content of container “ktexperts-jenkins”.
Key Points
Demonized Mode (Even Though you exit from container,those will be running).
Container is running without going inside the container.
Mapping 2 ports while running the docker run command.
one port for base machine (Docker) and another one for container (ktexperts-webserver).
We can change host port but can’t container port.
We need to add port 8080 in SG of Docker.
Container don’t have any IP Address but it has port.
We access the container web content through base machine IP Address.
Thank you for giving your valuable time to read the above information.
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTEXPERTS is always active on below social media platforms.
Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform