Issue running confluence in docker with mysql
Asked by GastonLesgaffes:

Hi,

I am trying to run confluence in a docker container with a mysql db as somebody else did (<https://community.atlassian.com/t5/Confluence-questions/How-do-I-connect-a-Confluence-container-to-a-MySQL-container/qaq-p/1074560> ), however, I am having issue, the mysql container keeps exiting with code 2 and then restarting, I am at a loss

here is my code:

dockerfile to create confluence_db image:

```
FROM atlassian/confluence-server
COPY mysql-connector-java-5.1.47.jar /opt/atlassian/confluence/confluence/WEB-INF/lib
```

docker-compose.yml

```
version: '3'
services:
confl-mysql:
image: mysql/mysql-server:5.7
restart: always
networks:
- confluencenet
volumes:
- ./data/mysql:/var/lib/mysql
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_DATABASE=confluence
- MYSQL_USER=confluence
- MYSQL_PASSWORD=confluence
command: [mysqld, --character-set-server=utf8, --collation-server=utf8_bin, --default-storage-engine=INNODB, --max_allowed_packet=256M, --innodb_log_file_size=2GB, --transaction-isolation=READ-COMMITTED, --binlog_format=row]

confluence:
image: confluence_db
restart: always
networks:
- confluencenet
volumes:
- ./data/conlfuence_mysql:/var/atlassian/application-data/confluence_mysql_5.7
ports:
- 8090:8090
- 8091:8091

networks:
confluencenet: {}
```

I am trying to run it on a mac mini with docker for mac

to build the container I run the following cmd

```
docker build -t confluence_db .
docker-compose up
```

afterwards, I run in a loop where the mysql container keeps crashing:

```
Creating confluence_mysql_confl-mysql_1 ... done
Creating confluence_mysql_confluence_1 ... done
Attaching to confluence_mysql_confl-mysql_1, confluence_mysql_confluence_1
confl-mysql_1 | [Entrypoint] MySQL Docker Image 5.7.29-1.1.15
confluence_1 | INFO:root:Generating /opt/atlassian/confluence/conf/server.xml from template server.xml.j2
confluence_1 | INFO:root:Generating /opt/atlassian/confluence/confluence/WEB-INF/classes/seraph-config.xml from template seraph-config.xml.j2
confluence_1 | INFO:root:Generating /opt/atlassian/confluence/confluence/WEB-INF/classes/confluence-init.properties from template confluence-init.properties.j2
confluence_1 | INFO:root:Generating /var/atlassian/application-data/confluence/confluence.cfg.xml from template confluence.cfg.xml.j2
confluence_1 | INFO:root:User is currently root. Will downgrade run user to confluence
confluence_1 | INFO:root:Running Confluence with command '/bin/su', arguments ['/bin/su', 'confluence', '-c', '/opt/atlassian/confluence/bin/start-confluence.sh -fg']
confluence_1 | executing as current user
confluence_1 | If you encounter issues starting up Confluence, please see the Installation guide at http://confluence.atlassian.com/display/DOC/Confluence+Installation+Guide
confluence_1 | 
confluence_1 | Server startup logs are located in /opt/atlassian/confluence/logs/catalina.out
confluence_1 | ---------------------------------------------------------------------------
confluence_1 | Using Java: /opt/java/openjdk/bin/java
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_1 | 2020-04-27 01:50:11,138 INFO [main] [atlassian.confluence.bootstrap.SynchronyProxyWatchdog] A Context element for ${confluence.context.path}/synchrony-proxy is found in /opt/atlassian/confluence/conf/server.xml. No further action is required
confluence_1 | ---------------------------------------------------------------------------
confluence_1 | NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
confluence_1 | [0.001s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/opt/atlassian/confluence/logs/gc-2020-04-27_01-50-11.log instead.
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confluence_1 | 27-Apr-2020 01:50:13.795 WARNING [main] org.apache.catalina.startup.SetAllPropertiesRule.begin [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'proxyPort' to '' did not find a matching property.
confluence_1 | 27-Apr-2020 01:50:13.999 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine] failed to set property [debug] to [0]
confluence_1 | 27-Apr-2020 01:50:14.015 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host] failed to set property [debug] to [0]
confluence_1 | 27-Apr-2020 01:50:14.269 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host/Context] failed to set property [debug] to [0]
confluence_1 | 27-Apr-2020 01:50:14.388 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host/Context] failed to set property [debug] to [0]
confluence_1 | 27-Apr-2020 01:50:14.401 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.27
confluence_1 | 27-Apr-2020 01:50:14.402 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Oct 7 2019 09:57:22 UTC
confluence_1 | 27-Apr-2020 01:50:14.403 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.27.0
confluence_1 | 27-Apr-2020 01:50:14.405 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
confluence_1 | 27-Apr-2020 01:50:14.406 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 4.19.76-linuxkit
confluence_1 | 27-Apr-2020 01:50:14.407 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
confluence_1 | 27-Apr-2020 01:50:14.410 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /opt/java/openjdk
confluence_1 | 27-Apr-2020 01:50:14.411 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 11.0.6+10
confluence_1 | 27-Apr-2020 01:50:14.412 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: AdoptOpenJDK
confluence_1 | 27-Apr-2020 01:50:14.417 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /opt/atlassian/confluence
confluence_1 | 27-Apr-2020 01:50:14.418 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /opt/atlassian/confluence
confluence_1 | 27-Apr-2020 01:50:14.432 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
confluence_1 | 27-Apr-2020 01:50:14.433 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
confluence_1 | 27-Apr-2020 01:50:14.433 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
confluence_1 | 27-Apr-2020 01:50:14.434 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/opt/atlassian/confluence/conf/logging.properties
confluence_1 | 27-Apr-2020 01:50:14.434 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
confluence_1 | 27-Apr-2020 01:50:14.435 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
confluence_1 | 27-Apr-2020 01:50:14.436 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
confluence_1 | 27-Apr-2020 01:50:14.437 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
confluence_1 | 27-Apr-2020 01:50:14.437 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:ReservedCodeCacheSize=256m
confluence_1 | 27-Apr-2020 01:50:14.438 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+UseCodeCacheFlushing
confluence_1 | 27-Apr-2020 01:50:14.438 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.server.protocols=TLSv1.1,TLSv1.2
confluence_1 | 27-Apr-2020 01:50:14.444 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.client.protocols=TLSv1.1,TLSv1.2
confluence_1 | 27-Apr-2020 01:50:14.445 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dconfluence.context.path=
confluence_1 | 27-Apr-2020 01:50:14.445 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Datlassian.plugins.startup.options=-fg
confluence_1 | 27-Apr-2020 01:50:14.445 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.locale.providers=JRE,SPI,CLDR
confluence_1 | 27-Apr-2020 01:50:14.446 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE=32768
confluence_1 | 27-Apr-2020 01:50:14.446 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dsynchrony.enable.xhr.fallback=true
confluence_1 | 27-Apr-2020 01:50:14.446 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms1024m
confluence_1 | 27-Apr-2020 01:50:14.446 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx1024m
confluence_1 | 27-Apr-2020 01:50:14.459 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dconfluence.home=/var/atlassian/application-data/confluence
confluence_1 | 27-Apr-2020 01:50:14.459 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+UseG1GC
confluence_1 | 27-Apr-2020 01:50:14.461 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Datlassian.plugins.enable.wait=300
confluence_1 | 27-Apr-2020 01:50:14.462 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.awt.headless=true
confluence_1 | 27-Apr-2020 01:50:14.463 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:G1ReservePercent=20
confluence_1 | 27-Apr-2020 01:50:14.464 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xloggc:/opt/atlassian/confluence/logs/gc-2020-04-27_01-50-11.log
confluence_1 | 27-Apr-2020 01:50:14.465 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+UseGCLogFileRotation
confluence_1 | 27-Apr-2020 01:50:14.500 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:NumberOfGCLogFiles=5
confluence_1 | 27-Apr-2020 01:50:14.500 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:GCLogFileSize=2M
confluence_1 | 27-Apr-2020 01:50:14.500 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xlog:gc+age=debug:file=/opt/atlassian/confluence/logs/gc-2020-04-27_01-50-11.log::filecount=5,filesize=2M
confluence_1 | 27-Apr-2020 01:50:14.501 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:-PrintGCDetails
confluence_1 | 27-Apr-2020 01:50:14.501 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+PrintGCDateStamps
confluence_1 | 27-Apr-2020 01:50:14.501 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:-PrintTenuringDistribution
confluence_1 | 27-Apr-2020 01:50:14.502 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+IgnoreUnrecognizedVMOptions
confluence_1 | 27-Apr-2020 01:50:14.518 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
confluence_1 | 27-Apr-2020 01:50:14.518 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/opt/atlassian/confluence
confluence_1 | 27-Apr-2020 01:50:14.520 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/opt/atlassian/confluence
confluence_1 | 27-Apr-2020 01:50:14.524 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/atlassian/confluence/temp
confluence_1 | 27-Apr-2020 01:50:14.525 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confluence_1 | 27-Apr-2020 01:50:15.846 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8090"]
confluence_1 | 27-Apr-2020 01:50:15.895 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [2,964] milliseconds
confluence_1 | 27-Apr-2020 01:50:16.149 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
confluence_1 | 27-Apr-2020 01:50:16.150 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.27]
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_1 | SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
confluence_1 | SLF4J: Defaulting to no-operation (NOP) logger implementation
confluence_1 | SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
confluence_1 | 27-Apr-2020 01:50:22.432 INFO [Catalina-utility-2] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
confluence_mysql_confl-mysql_1 exited with code 2
confluence_1 | 27-Apr-2020 01:50:23.019 INFO [Catalina-utility-2] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
confluence_1 | 27-Apr-2020 01:50:23.447 INFO [Catalina-utility-2] org.apache.catalina.core.ApplicationContext.log Initializing Spring DispatcherServlet 'dispatcher'
confluence_1 | 2020-04-27 01:50:24,951 INFO [Catalina-utility-1] [com.atlassian.confluence.lifecycle] contextInitialized Starting Confluence 7.3.3 [build 8401 based on commit hash c6283eee88c6e2ccea8cfe01744df4489cbaea22] - synchrony version 3.1.0-master-0f086db5
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confluence_1 | 2020-04-27 01:50:34,405 WARN [Catalina-utility-1] [com.atlassian.config.ApplicationConfig] setApplicationHome Application home does not exist. Creating directory: /var/atlassian/application-data/confluence/shared-home
confluence_1 | 2020-04-27 01:50:34,418 INFO [Catalina-utility-1] [atlassian.confluence.cluster.DefaultClusterConfigurationHelper] lambda$saveSetupConfigIntoSharedHome$9 Writing setup configuration into shared home...
confluence_1 | 2020-04-27 01:50:34,434 INFO [Catalina-utility-1] [atlassian.confluence.cluster.DefaultClusterConfigurationHelper] lambda$saveSetupConfigIntoSharedHome$9 Finished writing setup configuration into shared home
confluence_1 | WARNING: An illegal reflective access operation has occurred
confluence_1 | WARNING: Illegal reflective access by org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender (file:/opt/atlassian/confluence/confluence/WEB-INF/lib/org.apache.felix.framework-5.6.12.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
confluence_1 | WARNING: Please consider reporting this to the maintainers of org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender
confluence_1 | WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
confluence_1 | WARNING: All illegal access operations will be denied in a future release
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confluence_1 | 27-Apr-2020 01:50:54.833 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8090"]
confluence_1 | 27-Apr-2020 01:50:54.994 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [39,119] milliseconds
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
confl-mysql_1 | [Entrypoint] Starting MySQL 5.7.29-1.1.15
confluence_mysql_confl-mysql_1 exited with code 2
```

I am at a loss of why it is crashing and welcome any help, I would really like to get it working because I like the facility of deploying a container on a local machine!

Thanks


Answers:
author: Dave Chevell
body: Hey [@GastonLesgaffes](/t5/user/viewprofilepage/user-id/1806442)

I tried your **docker-compose.yml** locally and I couldn't reproduce your error - everything started correctly. From your logs, Confluence isn't having startup issues, just MySQL - have you got pre-existing data at **./data/mysql**? If so, I'd suggest retrying with a clean slate to see if the issue reoccurs.

Ultimately if it's a MySQL startup error, more information would be needed beyond the exit code to determine the scope of the issue. Can you start a standalone MySQL container with the same env variables and command, or does it fail in the same way?


Tags: confluence-server

server