简体   繁体   English

无法连接到詹金斯管道上的 myslq docker 容器

[英]Unable to connect to myslq docker container on jenkins pipeline

I am trying to connect to mysql docker container that i created using docker compose.我正在尝试连接到我使用 docker compose 创建的 mysql docker 容器。

version: '3.1'
services:
  mysql:
    image: mysql:5.7.12
    ports:
      - "6033:3306"
    command: --sql_mode="" --default-authentication-plugin=mysql_native_password --transaction-isolation=READ-UNCOMMITTED
    restart: always
    container_name: docker-mysql
    environment:
      MYSQL_DATABASE: transaction_summary
      MYSQL_ROOT_PASSWORD: root

then in the pipeline script i run the.gradlew test command to run the test.然后在管道脚本中我运行 .gradlew 测试命令来运行测试。 However, it fails and complains about not being able to connect to the database.但是,它失败并抱怨无法连接到数据库。 Jenkins label used is Ubuntu-18. Jenkins 使用的标签是 Ubuntu-18。 My url looks like this in the application.我的网址在应用程序中看起来像这样。

url: jdbc:mysql://localhost:6033/transaction_summary

When i run it on my laptop, it runs fine.当我在笔记本电脑上运行它时,它运行良好。 But it is failing on jenkins.但它在詹金斯身上失败了。 I added docker ps in the jenkins script to makee sure the container is running.我在 jenkins 脚本中添加了 docker ps 以确保容器正在运行。 and it is running giving me the following details:它正在运行,为我提供以下详细信息:

197fbf0c793a   mysql:5.7.12  "docker-entrypoint.s…"  0.0.0.0:6033->3306/tcp  docker-mysql

I've tried 127.0.0.1, 0.0.0.0, 127.0.0.2 instead of localhost.我试过 127.0.0.1、0.0.0.0、127.0.0.2 而不是 localhost。 and it still complains.它仍然抱怨。

May be try image name, ie mysql url could look like jdbc:mysql://mysql:6033/transaction_summary可能是尝试图像名称,即mysql url 可能看起来像jdbc:mysql://mysql:6033/transaction_summary

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM