Thursday, 17 February 2022

How to Connect to a running container- Unlock Jenkins Password in Docker

 Prerequisite:

Make sure you complete this lab: https:/www.devopstreams.com/2022/02/how-to-pull-images-from-docker.html before attempting this


You can connect to a running container just like you can connect to a server and then run commands in that container. To do that you have to make use of the docker exec command

Step 1: Create a Container from a Jenkins image. see https:/www.devopstreams.com/2022/02/how-to-pull-images-from-docker.html

docker pull jenkins/jenkins:lts
docker images
docker run -itd -p 8010:8080 -p 51000:50000 jenkins/jenkins:lts
docker ps -a

Step 3. Connect to your running container 

docker exec -it container_id sh--------->replace ur container id in red

docker exec -it 65357f31b2bc sh



This will connect you to the shell of the container.
Step 3: Unlock Jenkins : Now you are connected to the container shell, you can access the path of the Jenkin initial password

$ cat /var/jenkins_home/secrets/initialAdminPassword


Step 4: Unlock Jenkins in the UI





No comments:

Post a Comment

Understanding Software Testing Using a Simple JSP Web App

  🎯 Lab Context (Very Important) This project is a basic Maven web application created for learning DevOps concepts. It displays a sim...