1.6 KiB
Jenkins with Docker Compose
Jenkins docker compose file (and instructions) to configure your jenkins controller and agent.
Configuring Jenkins
-
Create the jenkins_home folder in your local environment
mkdir jenkins_sandbox_home -
Create a file named .env and add the following:
JENKINS_HOME_PATH=/home/user/jenkins_sandbox_home # your local jenkins_home path. JENKINS_AGENT_SSH_PUBLIC_KEY=<< leave empty for now >> -
Run Jenkins controller:
docker-compose up -d -
Get the password to proceed installation:
docker logs jenkins_sandbox | less -
Go to http://localhost:8080/ and enter the password.
-
Select Install Suggested Plugins, create the admin user and password, and leave the Jenkins URL http://localhost:8080/.
Configuring Jenkins Agent
-
Use ssh-keygen to create a new key pair:
ssh-keygen -t rsa -f jenkins_key -
Go to Jenkins and click Manage jenkins > Manage credentials.
-
Under Stores scoped to Jenkins, click Global credentials, next click Add credentials and set the following options:
- Select SSH Username with private key.
- Limit the scope to System.
- Give the credential an ID.
- Provide a description.
- Enter a username.
- Under Private Key check Enter directly.
- Paste the content of private key in the text box.
-
Click Ok to save.
-
Paste the public key on the JENKINS_AGENT_SSH_PUBLIC_KEY variable, in the .env file.
-
Recreate the services:
docker-compose down docker-compose up -d