In this article, we will see how to run Jenkins, GitLab, and Bitbucket docker images in a container on Docker-desktop installed on Windows. Ensure Docker-desktop is running on Windows allowing you to run Linux Containers.
All the persisted Volumes on the host will be found in this folder-
\\wsl$\docker-desktop-data\version-pack-data\community\docker
or in Docker-desktop dashboard
Jenkins:
>> Create Dockerfile with this content (it will install .Net & Gitversion as well) and build it to create a new image-
FROM jenkins/jenkins:2.319.1-jdk11 USER root RUN apt-get update && apt-get install -y lsb-release RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \ https://download.docker.com/linux/debian/gpg RUN echo "deb [arch=$(dpkg --print-architecture) \ signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \ https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list RUN apt-get update && apt-get install -y docker-ce-cli #added by me # Add Microsoft package signing key to trusted keys (to allow installation of .net sdk) RUN curl -o packages-microsoft-prod.deb -L https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb \ && dpkg -i packages-microsoft-prod.deb \ && rm packages-microsoft-prod.deb # Install dotnet 5.0 RUN apt-get update && apt-get install -y --no-install-recommends \ apt-transport-https \ dotnet-sdk-5.0 # Add dotnet tools to path ENV PATH=$PATH:~/.dotnet/tools # Install GitVersion (using dotnet tool install) RUN dotnet tool install --global --version 5.8.1 GitVersion.Tool ######## USER jenkins RUN jenkins-plugin-cli --plugins "blueocean:1.25.2 docker-workflow:1.26"
>> Run this command to create a new image
docker build -t jenkins-with-dotnet:1.0 .
>>Start the Jenkins container
docker run --name jenkins-with-dotnet --rm --detach \
--env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
--publish 8080:8080 --publish 51000:50000 jenkins-with-dotnet:1.0
>> Try to access the Jenkins using – http://localhost:8080
>> To unlock Jenkins, follow this article- https://www.jenkins.io/doc/book/installing/docker/ to get the password.
docker exec ${CONTAINER_ID or CONTAINER_NAME} cat /var/jenkins_home/secrets/initialAdminPassword
Now it will take you through a number of screens to create a user and then you will be able to access Jenkins.
Run Jenkins & bitbucket as containers in Docker-desktop
Bitbucket:
Just start the Bitbucket container using this command
docker run -v /data/bitbucket:/var/atlassian/application-data/bitbucket --name="bitbucket" -d -p 7990:7990 -p 7999:7999 atlassian/bitbucket
Once the container is up and running, access it using- http://localhost:7990
GitLab:
Start the GitLab using the docker command
docker run --name gitlab --detach \
--env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--restart always \
--volume gitlab-config:/etc/gitlab \
--volume gitlab-logs:/var/log/gitlab \
--volume gitlab-data:/var/opt/gitlab \
--shm-size 256m gitlab/gitlab-ee:latest
It will take some to start the container. You can access it using http://localhost:80
It will show the login screen, use username as root, and find the password using this command
docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
Run Jenkins & bitbucket as containers in Docker-desktop
References:
https://www.jenkins.io/doc/book/installing/docker/
https://docs.gitlab.com/ee/install/docker.html