OS: macOS High Sierra 10.13
Download Docker for Mac
Create Docker ID
You need to go to https://www.docker.com/ to create you own docker id.
Download Jenkins CI with blue ocean plugin.
Download link: https://hub.docker.com/r/jenkinsci/blueocean/ .
Follow the installation instructions to install the jenkinsci/blueocean Docker container. And do remember to launch the Docker.app after installation as launching the application is a necessary step to get the Docker daemon run.
Start the Jenkins CI container
$ docker run -u root --rm -d -p 8080:8080 -p 50000:50000 -v jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean
--rm is to remove the docker container after it is shut down. -d is to let jenkinsci container run in background and silent the output rather than print out in terminal console. Recommend not to add this option, because usually you want to check the output from terminal console, e.g. the initial password. -p 8080:8080 is the to map the port number for host machine and docker container respectively. -p 50000:50000 is for the JNLP based Jenkins master-slave configurations. JNLP-based Jenkins agents communicate with the Jenkins master through TCP port 50000 by default. -v jenkins-data:/var/jenkins_home is to map the
/var/jenkins_homedirectory in the container to the Docker volume with the name
jenkins-data, this option is to ask Jenkins to persist state for instance restarts.-v /var/run/docker.sock:/var/run/docker.sock, this option is to allow jenkins ci container to communicate with docker daemon. jenkinsci/blueocean is the jenkinsci image with blueocean plugin, specifying this option will automatically pull any updates.
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See 'docker run --help'.
This error is because the Docker daemon is not started yet. On MacOS, you need to manually start the Docker.app in order to let the docker daemon start.
Open the Jenkins landing page
Browse http://localhost:8080/ , you will see below page.
Find the password from console output and paste it above input box to continue.
If you suddenly lost your initial password from the console output. You can use below command to get it back. Also, actually this password is your default password for your Jenkins admin account.
$ docker exec cat /var/jenkins_home/secrets/initialAdminPassword
You can ask the Jenkins to install the suggested plugins for you or choose the ones you need only. You can also install the plugins from “Manage Plugins” after you complete the Jenkins setup.
Create your first jenkins account
You can create your own jenkins account during the setup phase. Or you can also ignore this step but use the “admin” account with its default password, the one output in console, for login.
If your Jenkins server is behind a proxy, then you need to configure this proxy properly in order to install your Jenkins plugins. Navigate yourself to “Manage Jenkins” -> “Manager Plugins” -> “Advanced“.
Some useful commands
Check container IDs
docker ps -a
Check logs for a particular container
docker logs <container-id>