skip to Main Content

I’m trying to configure jira on a CentOS 7 virtual machine.
I managed to launch Jira’s docker image without any problems with a docker-compose :

 jira:
    image: 'cptactionhank/atlassian-jira-software:latest'
    container_name: jira
    restart: unless-stopped
    healthcheck:
      disable: true
    volumes:
      - '/var/atlassian/jira:/var/atlassian/jira'

I also installed mySQL on my virtual machine (without using a docker) while following the installation procedure described here:
https://confluence.atlassian.com/adminjiraserver/connecting-jira-applications-to-mysql-5-6-938846854.html

Including :

CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'jiradbuser'@'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON jiradb.* TO 'jiradbuser'@'%' IDENTIFIED BY 'secret';
flush privileges;

MySQL is accessible on my localhost port 3306 (the command telnet 0.0.0.0 3306 answers me well)

I also downloaded the 5.1.38 connector-j from MySQL and since I didn’t have a lib folder in my /var/atlassian/jira, I created it with a mkdir and unzipped the jar in it.

I restart Jira with:

docker-compose stop jira
docker-compose rm jira
docker-compose start jira

Now, I go on my browser to the jira software address, at the time of the Database setup, I entered this information :

Database Connection: My Own Database 
Database Type: MySQL 5.6
Hostname: localhost
Port: 3306
Database: jiradb
Username: jiradbuser
Password: secret

When I click on “Test Connection”, it doesn’t work. The answer is :

Error connecting to database

Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Connection refused (Connection refused)

The log of jira when I click on “Test Connection” is below :

==> atlassian-jira.log <==
2019-07-19 14:42:37,906 http-nio-8080-exec-21 ERROR anonymous 882x13x1 b45eq1 10.107.135.18,172.18.0.3 /secure/SetupDatabase!connectionCheck.jspa [c.a.config.bootstrap.DefaultAtlassianBootstrapManager] Could not successfully test your database:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
  at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)
  at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:339)
  at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)
  at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2286)
  at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2085)
  at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795)
  at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
  ... 3 filtered
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
  at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
  at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
  at java.sql.DriverManager.getConnection(DriverManager.java:664)
  at java.sql.DriverManager.getConnection(DriverManager.java:247)
  at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.getTestDatabaseConnection(DefaultAtlassianBootstrapManager.java:347)
  at com.atlassian.jira.config.database.JdbcDatasource.getConnection(JdbcDatasource.java:211)
  at com.atlassian.jira.config.database.DatabaseConfig.testConnection(DatabaseConfig.java:88)
  at com.atlassian.jira.web.action.setup.SetupDatabase.testConnection(SetupDatabase.java:230)
  at com.atlassian.jira.web.action.setup.SetupDatabase.doValidation(SetupDatabase.java:194)
  at com.atlassian.jira.web.action.setup.SetupDatabase.doConnectionCheck(SetupDatabase.java:126)
  ... 3 filtered
  at java.lang.reflect.Method.invoke(Method.java:498)
  at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:70)
  at webwork.util.InjectionUtils.invoke(InjectionUtils.java:56)
  ... 2 filtered
  at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
  ... 7 filtered
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
  ... 49 filtered
  at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66)
  ... 1 filtered
  at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64)
  ... 31 filtered
  at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
  ... 24 filtered
  at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
  ... 25 filtered
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
  at java.net.PlainSocketImpl.socketConnect(Native Method)
  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
  at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
  at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:298)
  ... 175 more

Is there anything I’m not doing right?

Thank you in advance.

Hugo

3

Answers


  1. Chosen as BEST ANSWER

    Hello and thank you for your answer. The network_mode: "host" didn't work for me because I also use Traefik. But you put me on the right track and this outcome helped me: How to connect locally hosted MySQL database with the docker container The solution to my problem was to use this command :

    docker inspect <container-id-or-name> | grep Gateway
    "Gateway": "",
                "IPv6Gateway": "",
                "Gateway": "172.18.0.1",
                "IPv6Gateway": "",
    

    And use 172.18.0.1 instead of "localhost" for the "host" field of my local mySQL database


  2. Mysql database is running on host (non-docker) at port 3306.

    While Jira is running inside container. By-default container runs in bridge networking mode, where container network is different from host network. Hence localhost inside container is not the same as on host.

    Here you can do two things:

    • In your Jira container refer to mysql database using private/public-ip:3306

    OR

    • Run Jira docker container in host networking mode, so that localhost inside container is same as that on host. Because in this mode container uses network of host.
     jira:
        image: 'cptactionhank/atlassian-jira-software:latest'
        container_name: jira
        restart: unless-stopped
        healthcheck:
          disable: true
        volumes:
          - '/var/atlassian/jira:/var/atlassian/jira'
        network_mode: "host"
    

    NOTE: network_mode: "host" option will tell docker container to use host networking mode.

    Login or Signup to reply.
  3. My solution was to set host.docker.internal instead of localhost in the connection url in the dbconfig.xml file. In the Dockerfile I have the following lines:

    EXPOSE 3306
    VOLUME ["/var/atlassian/application-data/jira"]
    

    I hope it helps

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search