I am (relatively) new to Docker and I want to know some more about Jenkins so I thought I'd use Docker to run the latest version of Jenkins. This is a warts and all step through my progress.
I've heard that Docker containers can run in Azure without a virtual machine but I wanted to understand how it all works so I decided to create a Windows 10 virtual machine and install Docker on that.
I created the Azure VM (using the UI), using the Windows 10 N (x64) image.
Once the machine had been created I then installed the Desktop edition of Docker, which can be found here:
I went with the default options and click Ok to let it unpack the files:
After that had completed the installation it wanted to log out, I went for a reboot:
Once the machine had rebooted I logged in and after Docker had started I was presented with this message:
As Docker uses Container and Hyper-V Windows features I'm only to happy for this to be setup automatically for me.
Once this had completed the VM had rebooted Docker prompted me to login with my Docker account.
Ok, so at this point Docker is installed and the VM has all the components to run Docker containers.
Next step was to get Jenkins running!
As I wanted the data to persist I created a folder structure on the VM; C:\Gruss\Docker\Jenkins.
I opened an Administrative PowerShell windows (not sure if I needed to run it with Administrator privileges or not) and ran the following command:
docker run -p 8080:8080 -p 50000:50000 -v
C:\Gruss\Docker\Jenkins:/var/jenkins_home jenkins/jenkins:lts
- -p 8080:8080
- This maps port 8080 on the VM to port 8080 within the container
- -p 50000:50000
- This maps the port in the same way above
- -v C:\Gruss\Docker\Jenkins:/var/jenkins_home
- This creates a volume mount so that information in the container can be persisted after reboots etc. In this case I'm storing the data in C:\Gruss\Docker
As the Docker image was not local to my Azure VM Docker proceeded to download the container for me:
Docker informed me to store the configuration on 'C:\Gruss\Docker' folder it needed permission to do this:
Having clicked 'Share it', an account was needed:
At this point Docker spat out an error message:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint goofy_lederberg (deaba2deeea0486c92ba8a1a32740295f03859b1b5829d39e39eff0b24613ebf): Error starting userland proxy: Bind for 0.0.0.0:50000: unexpected error Permission denied.
This is stating that it could not map port 50000 on the local machine, possibly because it was in use. I ran netstat to list all of the ports that were in use:
netstat -a -n -oNothing was using port 50000, something strange was going on.
I was able to start the VM removing the ‘-p 50000:50000’ but
I’ve assumed it needs to map this port in order to work correctly.
Coming back the following morning (after shutting down the
vm) all was resolved so perhaps a reboot was all it needed?
Ok so now I’ve run the command and my docker
container is running! (wahoo!!!)
Open a browser on the VM and go to: Http://localhost:8080
However, as I started the container removing the port 50000 mapping I don't have the administrator password to start Jenkins.
However, it states that it is available by browsing to /var/jenkins_home/secrets/initialAdminPassword
As I started the container previously the Admin password isn’t now shown in the output when starting the container (it is only shown the first time), so I now need to browse the local file system of the container to get the password.
To do this I opened a new PowerShell window.
The Docker ps command lists the running containers and it also
lists the ‘name’ for it, which in my case is called dreamy_bhabha.
With that I can exec a command on the image:
docker exec dreamy_bhabha cat /var/jenkins_home/secrets/initialAdminPassword
I've since found that I could have browsed to the C:\Gruss\Docker\Jenkins\secrets folder but where is the fun in that?
Typing that password in allows Jenkins to start:
I went with the option to install the suggested plugins and
off it went:
After creating the user Jenkins seemed to crash for me, as I
was presented with a blank page.
Trying
in an incognito window showed the login screen but after logging in I got the
blank page.
To resolve this I stopped the container:
docker stop dreamy_bhabha
Then restarted it:
docker run -p 8080:8080 -p 50000:50000 -v
jenkins_home:/var/jenkins_home jenkins/jenkins:lts
Note: This will give
me a new name for the container.
Opening a browser allowed me to login and see that Jenkins
is now working:
Next step will be creating a pipeline in Jenkins!
This comment has been removed by a blog administrator.
ReplyDelete