# \[Docker] 1. Setup Jenkins with Docker on Mac

### (1.) Download Docker for Mac

Download link:

{% embed url="<https://www.docker.com/products/docker-desktop>" %}

###

### (2.) Download Jenkins CI with blue ocean plugin.

Download link:

&#x20;<https://hub.docker.com/r/jenkinsci/blueocean/>

Follow the installation instructions to install the **jenkinsci/blueocean** Docker container.&#x20;

### (3.)  Start the Jenkins CI container

```swift
$ docker run --name jenkins -u root -d -p 8080:8080 -p 50000:50000 -v jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean
```

Command options:

```swift
--name 
container name

-d 
is to let jenkinsci container run in background and silent the output rather
than print out in terminal console. 

-p 8080:8080 
is the to map the port number for host machine and docker container respectively.
(Service port : Jenkins port)

-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_home directory 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.  
```

After start Jenkins, you can use the below command to check the container status:

```swift
docker ps -a
```

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LYUSxLfD9o51bApMVjt%2F-LYUULNw_5413n6m6Xdg%2F%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202019-02-12%20%E4%B8%8A%E5%8D%8810.13.34.png?alt=media\&token=5d0f7e63-4590-4040-8874-ec02335e8672)

Docker commands:

```swift
//start a container:
docker start <container name>

//stop a container:
docker stop <container name>

//remove a container:
docker rm <container name>

//restart a container:
docker restart  <container name>
```

#### (4.) Browse <http://localhost:8080/> , you will see below page.

![](https://1235580532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHkCJzI8ydp2uTYXgFk%2F-LYUf6QbqQJ8CIATVyjU%2F-LYUgd6ry4AOURp0U2p4%2F%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202019-02-12%20%E4%B8%8A%E5%8D%8811.13.32.png?alt=media\&token=6e2d0cb8-4844-49f7-bbd8-c07636fba3ed)

####

#### ( 5.) Find the password by below command

```swift
docker exec <container> cat /var/jenkins_home/secrets/initialAdminPassword
```
