jenkins-docs / quickstart-tutorials

Jenkins tutorial files
MIT License
10 stars 178 forks source link

Error when running "docker compose --profile multi up -d" #454

Open ajunx8 opened 2 months ago

ajunx8 commented 2 months ago

Error response from daemon: driver failed programming external connectivity on endpoint quickstart-tutorials-jenkins_controller-1 (99d73499cbeccad5211e1eb***bd3fb443b904dcddcab2a6): Bind for 0.0.0.0:8080 failed: port is already allocated


Purpose: Trying to follow the tutorial "End-to-End Multibranch Pipeline Project Creation" What I've done:

  1. Followed the tutorial "Build a Node.js and React app with npm"
  2. got up to the step where I run "docker compose --profile node up -d".
  3. Everything worked fine. *4. Tried to complete the tutorial "End-to-End Multibranch Pipeline Project Creation"
  4. Ran "docker compose --profile multi up -d". Encountered Above error.
  5. Proceed anyway onto step "Create your Multibranch Pipeline project". Ran into these warnings and had to wait. The status for the branches are in waiting for too long.
    07:00:56 Jenkins-Imposed API Limiter: Current quota for Github API usage has 52 remaining (1 over budget). Next quota of 60 in 59 min. Sleeping for 5 min 5 sec.
    07:00:56 Jenkins is attempting to evenly distribute GitHub API requests. To configure a different rate limiting strategy, such as having Jenkins restrict GitHub API requests only when near or above the GitHub rate limit, go to "GitHub API usage" under "Configure System" in the Jenkins settings.
    07:03:57 Jenkins-Imposed API Limiter: Still sleeping, now only 2 min 3 sec remaining.

What I've tried:

  1. I've tried to remove everything from docker with "docker system prune" and other commands,
  2. restart docker
  3. update docker to latest version (from v4.23.0 to v4.32.0)
  4. restart my machine (MacOS 14.4.1)
  5. Delete and re-clone quickstart-tutorials repo

Notes:

  1. "docker-ssh-jenkins-agent" Node is failing to start. These are the logs
    SSHLauncher{host='desktop-jenkins_agent-1', port=22, credentialsId='jenkins-ssh-agent-private-key', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
    [07/18/24 07:32:12] [SSH] Opening SSH connection to desktop-jenkins_agent-1:22.
    desktop-jenkins_agent-1: Name or service not known
    SSH Connection failed with IOException: "desktop-jenkins_agent-1: Name or service not known", retrying in 15 seconds. There are 10 more retries left.
    desktop-jenkins_agent-1: Name or service not known
    .
    .
    .
    ERROR: Connection is not established!
    java.lang.IllegalStateException: Connection is not established!
    at com.trilead.ssh2.Connection.getRemainingAuthMethods(Connection.java:989)
    at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPublicKeyAuthenticator.getRemainingAuthMethods(TrileadSSHPublicKeyAuthenticator.java:89)
    at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPublicKeyAuthenticator.canAuthenticate(TrileadSSHPublicKeyAuthenticator.java:81)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.base/java.util.Spliterators$IteratorSpliterator.tryAdvance(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline.findFirst(Unknown Source)
    at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:222)
    at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:173)
    at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:882)
    at hudson.plugins.sshslaves.SSHLauncher.lambda$launch$0(SSHLauncher.java:441)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
    [07/18/24 07:34:57] Launch failed - cleaning up connection
    [07/18/24 07:34:57] [SSH] Connection closed.
    1. Checking quickstart-tutorials-jenkins_controller-1 on docker container Logs
      WARNING h.plugins.sshslaves.SSHLauncher#launch: SSH Launch of docker-ssh-jenkins-agent on desktop-jenkins_agent-1 failed in 165,116 ms
      INFO    hudson.slaves.SlaveComputer#tryReconnect: Attempting to reconnect docker-ssh-jenkins-agent
  2. Docker Compose version v2.28.1-desktop.1
  3. Docker Client: Version: 27.0.3

Side-note: *Among this step, you need to create "development" and "production" branches, however "git checkout development" returns errors saying development does not exist. I presume it should be "git checkout -b development". Same for production.

Please help, I want to complete this tutorial.

gounthar commented 2 months ago

Hello @ajunx8,

Thank you for taking the time to create this issue. We greatly appreciate your feedback as it helps us improve our documentation and user experience.

It appears that some instructions may be missing at the end of the tutorial. Let's try a potential solution together. If this resolves your problem, we will update the documentation accordingly.

Suggested Solution

Before starting the next tutorial, please try running the following command: docker compose --profile node down -v --remove-orphans This command will:

  1. Stop and remove all containers defined in the docker-compose file
  2. Remove associated volumes
  3. Remove any orphaned containers

Next Steps

  1. Please attempt this solution and let us know if it resolves the issue you encountered.
  2. If successful, we will update the tutorial to include this step, ensuring future users don't face the same problem.
  3. If the issue persists, please provide additional details about the error you're experiencing, and we'll work together to find a solution.

We appreciate your patience and collaboration in improving our documentation. Your input is invaluable in making our tutorials more comprehensive and user-friendly.

If you have any questions or need further assistance, please don't hesitate to ask. We're here to help!

ajunx8 commented 1 month ago

After running docker compose --profile node down -v --remove-orphans and then docker compose --profile multi up -d I still get the following error:

Error response from daemon: driver failed programming external connectivity on endpoint quickstart-tutorials-jenkins_controller-1 (76e17cd7cdb7db82e508ac733ef254a534b67fce7a25ccaa6553673ec27df9af): Bind for 0.0.0.0:8080 failed: port is already allocated

I enter into localhost:8080 and check the Dashboard > Nodes > docker-ssh-jenkins-agent > Logs and I still get the error:

desktop-jenkins_agent-1: Name or service not known
SSH Connection failed with IOException: "desktop-jenkins_agent-1: Name or service not known", retrying in 15 seconds. 
gounthar commented 1 month ago

Troubleshooting Persistent Jenkins Controller

The down command should have resolved the issue. However, if you still have a Jenkins controller running on port 8080 after executing the command, you'll need to terminate it using an alternative method.

Option 1: Using Docker Desktop

If you're using Docker Desktop:

  1. Locate the quickstart-tutorials container
  2. Click the red "Delete" button to terminate it

Option 2: Using Command Line

To terminate the container via command line, follow these steps:

  1. List all running containers: docker container ls
  2. Find the container using port 8080: docker container ls | grep 8080
  3. Extract the container ID: docker container ls --format "{{.ID}}\t{{.Ports}}" | grep "0.0.0.0:8080->8080" | cut -f1
  4. Terminate the container using a one-liner: docker kill $(docker container ls --format "{{.ID}}\t{{.Ports}}" | grep "0.0.0.0:8080->8080" | cut -f1)

These steps should help you remove any lingering Jenkins controller instances and free up port 8080 for future use.

Note: Always exercise caution when using docker kill commands, especially in production environments.

ajunx8 commented 1 month ago

The issue still persists after spinning it up, then stopping the container through Option 2,

➜  quickstart-tutorials git:(main) docker compose --profile multi up -d
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
[+] Running 30/30
 ✔ jenkins_controller Pulled                                                                                                                               99.6s 
 ✔ multi Pulled                                                                                                                                            43.0s 
   ✔ 0f60e68dd20d Pull complete                                                                                                                             1.3s 
   ✔ a150a8f13603 Pull complete                                                                                                                            30.6s 
   ✔ acb61341d8dc Pull complete                                                                                                                            30.6s 
   ✔ 4f4fb700ef54 Pull complete                                                                                                                            30.6s 
   ✔ cd1a8d2724be Pull complete                                                                                                                            31.0s 
   ✔ 7367d34ba553 Pull complete                                                                                                                            31.0s 
   ✔ a2c17bc2b693 Pull complete                                                                                                                            31.0s 
   ✔ 8ebd94f84d79 Pull complete                                                                                                                            39.9s 
   ✔ 90349a2dd1b3 Pull complete                                                                                                                            39.9s 
 ✔ multi_jenkins_controller Pulled                                                                                                                         99.6s 
   ✔ 0bd1f8180c50 Already exists                                                                                                                            0.0s 
   ✔ 96b9209c146a Pull complete                                                                                                                            70.5s 
   ✔ 49d1d8c27bba Pull complete                                                                                                                            70.6s 
   ✔ 1b67e54696be Pull complete                                                                                                                            70.6s 
   ✔ d9b94d3f6c5c Pull complete                                                                                                                            70.6s 
   ✔ acdba9b30e9f Pull complete                                                                                                                            84.7s 
   ✔ 04e27316302b Pull complete                                                                                                                            84.7s 
   ✔ 0b5ed25beb7c Pull complete                                                                                                                            84.7s 
   ✔ b360fb53fcb2 Pull complete                                                                                                                            85.1s 
   ✔ 9a87b452193f Pull complete                                                                                                                            85.1s 
   ✔ 2cf9f9e2b657 Pull complete                                                                                                                            85.1s 
   ✔ f3cbb9e7358f Pull complete                                                                                                                            85.1s 
   ✔ e69dbe66420f Pull complete                                                                                                                            85.1s 
   ✔ ab7a3c7cedb6 Pull complete                                                                                                                            85.1s 
   ✔ 0048d08a0797 Pull complete                                                                                                                            85.1s 
   ✔ ed3c166a52fa Pull complete                                                                                                                            85.1s 
   ✔ ca9c5ec0c5d8 Pull complete                                                                                                                            96.6s 
   ✔ a4e5574c9d3d Pull complete                                                                                                                            96.6s 
[+] Running 5/6
 ✔ Network quickstart-tutorials_default                           Created                                                                                   0.0s 
 ✔ Container quickstart-tutorials-sidekick_service-1              Exited                                                                                    1.2s 
 ⠸ Container quickstart-tutorials-multi_jenkins_controller-1      Starting                                                                                  1.1s 
 ✔ Container quickstart-tutorials-discovery_and_jcasc_modifier-1  Started                                                                                   1.1s 
 ✔ Container quickstart-tutorials-jenkins_controller-1            Started                                                                                   1.1s 
 ✔ Container desktop-jenkins_agent-1-multi                        Created                                                                                   0.1s 
Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:8080 -> 0.0.0.0:0: listen tcp 0.0.0.0:8080: bind: address already in use
➜  quickstart-tutorials git:(main) docker container ls
CONTAINER ID   IMAGE                                                                              COMMAND                  CREATED              STATUS                                 PORTS                               NAMES
48db9925f7a0   ghcr.io/jenkins-docs/quickstart-tutorials/jenkinsci-tutorials:agent_discovery_     "sh -c /usr/local/bi…"   About a minute ago   Up About a minute (health: starting)                                       quickstart-tutorials-discovery_and_jcasc_modifier-1
bd934a10d6c4   ghcr.io/jenkins-docs/quickstart-tutorials/jenkinsci-tutorials:simple_controller_   "/usr/bin/tini -- /u…"   About a minute ago   Up About a minute (healthy)            0.0.0.0:8080->8080/tcp, 50000/tcp   quickstart-tutorials-jenkins_controller-1
➜  quickstart-tutorials git:(main) docker container ls | grep 8080
bd934a10d6c4   ghcr.io/jenkins-docs/quickstart-tutorials/jenkinsci-tutorials:simple_controller_   "/usr/bin/tini -- /u…"   3 minutes ago   Up 3 minutes (healthy)            0.0.0.0:8080->8080/tcp, 50000/tcp   quickstart-tutorials-jenkins_controller-1
➜  quickstart-tutorials git:(main) 
docker container ls --format "{{.ID}}\t{{.Ports}}" | grep "0.0.0.0:8080->8080" | cut -f1
bd934a10d6c4
➜  quickstart-tutorials git:(main) docker kill $(docker container ls --format "{{.ID}}\t{{.Ports}}" | grep "0.0.0.0:8080->8080" | cut -f1)
bd934a10d6c4
➜  quickstart-tutorials git:(main) docker container ls
CONTAINER ID   IMAGE                                                                            COMMAND                  CREATED         STATUS                            PORTS     NAMES
48db9925f7a0   ghcr.io/jenkins-docs/quickstart-tutorials/jenkinsci-tutorials:agent_discovery_   "sh -c /usr/local/bi…"   4 minutes ago   Up 4 minutes (health: starting)             quickstart-tutorials-discovery_and_jcasc_modifier-1
➜  quickstart-tutorials git:(main) docker compose --profile multi up -d                                                                   
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
[+] Running 3/4
 ✔ Container quickstart-tutorials-sidekick_service-1              Exited                                                                                    0.6s 
 ✔ Container quickstart-tutorials-discovery_and_jcasc_modifier-1  Running                                                                                   0.0s 
 ⠹ Container quickstart-tutorials-jenkins_controller-1            Starting                                                                                  0.8s 
 ✔ Container quickstart-tutorials-multi_jenkins_controller-1      Started                                                                                   0.1s 
Error response from daemon: driver failed programming external connectivity on endpoint quickstart-tutorials-jenkins_controller-1 (30f7e941244c4286b8dcf028917a90fb079662d08c0184bcf8a2179af169972f): Bind for 0.0.0.0:8080 failed: port is already allocated
➜  quickstart-tutorials git:(main) docker compose --profile multi down -v --remove-orphans
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
[+] Running 8/8
 ✔ Container quickstart-tutorials-discovery_and_jcasc_modifier-1  Removed                                                                                  10.2s 
 ✔ Container quickstart-tutorials-jenkins_controller-1            Removed                                                                                   0.0s 
 ✔ Container desktop-jenkins_agent-1-multi                        Removed                                                                                   0.0s 
 ✔ Container quickstart-tutorials-multi_jenkins_controller-1      Removed                                                                                   0.2s 
 ✔ Container quickstart-tutorials-sidekick_service-1              Removed                                                                                   0.0s 
 ✔ Volume agent-ssh-dir                                           Removed                                                                                   0.0s 
 ✔ Volume quickstart-tutorials_jenkins_home                       Removed                                                                                   0.0s 
 ✔ Network quickstart-tutorials_default                           Removed                                                                                   0.1s 
➜  quickstart-tutorials git:(main) docker compose --profile multi up -d                   
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
WARN[0000] The "GITPOD_WORKSPACE_URL" variable is not set. Defaulting to a blank string. 
[+] Running 7/8
 ✔ Network quickstart-tutorials_default                           Created                                                                                   0.0s 
 ✔ Volume "agent-ssh-dir"                                         Created                                                                                   0.0s 
 ✔ Volume "quickstart-tutorials_jenkins_home"                     Created                                                                                   0.0s 
 ✔ Container quickstart-tutorials-sidekick_service-1              Exited                                                                                    0.7s 
 ✔ Container quickstart-tutorials-jenkins_controller-1            Started                                                                                   0.8s 
 ✔ Container quickstart-tutorials-discovery_and_jcasc_modifier-1  Started                                                                                   0.8s 
 ⠸ Container quickstart-tutorials-multi_jenkins_controller-1      Starting                                                                                  0.8s 
 ✔ Container desktop-jenkins_agent-1-multi                        Created                                                                                   0.0s 
Error response from daemon: driver failed programming external connectivity on endpoint quickstart-tutorials-multi_jenkins_controller-1 (eee9b4ecf3523778029437c1a3bac432f73765d39d2753ad4aa60167ce2b8f9a): Bind for 0.0.0.0:8080 failed: port is already allocated
➜  quickstart-tutorials git:(main) lsof -i :8080                       
COMMAND    PID         USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
firefox    859 adriangreksa  126u  IPv4 0xcdbcbb0292e895a9      0t0  TCP localhost:55523->localhost:http-alt (ESTABLISHED)
firefox    859 adriangreksa  168u  IPv4 0xcdbcbb02907ce129      0t0  TCP localhost:55525->localhost:http-alt (ESTABLISHED)
com.docke 2194 adriangreksa   51u  IPv6 0xcdbcbaef61ea16d9      0t0  TCP localhost:http-alt->localhost:55523 (ESTABLISHED)
com.docke 2194 adriangreksa   58u  IPv6 0xcdbcbaef61e9b6d9      0t0  TCP localhost:http-alt->localhost:55525 (ESTABLISHED)
com.docke 2194 adriangreksa  110u  IPv6 0xcdbcbaef61e9a6d9      0t0  TCP *:http-alt (LISTEN)

Tried to start the tutorial anyway, but got up to the "Create your Multibranch Pipeline project" step 9. Dashboard > Building a Multibranch Pipeline Project > master > #.1 > Console Output

Branch indexing
05:29:30 Connecting to https://api.github.com/ with no credentials, anonymous access
Obtained Jenkinsfile from e9ed5b1a67fd903ce791ac59bf1b87899c8852d5
[Pipeline] Start of Pipeline
[Pipeline] node
Still waiting to schedule task
‘[docker-ssh-jenkins-agent](http://localhost:8080/computer/docker%2Dssh%2Djenkins%2Dagent/)’ is offline