DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Keep Your Application Secrets Secret
  • How to Run a MySQL Database in a Docker Container
  • Integrating Spring Boot Microservices With MySQL Container Using Docker Desktop
  • The Power of ShardingSphere With Spring Boot

Trending

  • Cloud Security and Privacy: Best Practices to Mitigate the Risks
  • How To Introduce a New API Quickly Using Quarkus and ChatGPT
  • Docker Base Images Demystified: A Practical Guide
  • Why Database Migrations Take Months and How to Speed Them Up
  1. DZone
  2. Data Engineering
  3. Databases
  4. Installing and Configuring Atlassian Confluence With MySQL in Docker Containers

Installing and Configuring Atlassian Confluence With MySQL in Docker Containers

Read this article to find out how to build a docker-compose file to create a container from an image together with a container running MySQL.

By 
Kevin Hooke user avatar
Kevin Hooke
·
Jul. 19, 18 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
17.5K Views

Join the DZone community and get the full member experience.

Join For Free

Atlassian Confluence is already available as a Docker Image from the Docker Hub, but you still need to provide a database instance for a production setup. Let's build a docker-compose file to create a container from this image together with a container running MySQL.

First, per the docs on the Docker Hub page, create an external folder /data/confluence that will get mounted as a volume by the Container.

This is my first version to get this working (keep reading for refining this to include a JDBC driver).

version: '3'
services:
  confluence:
    image: atlassian/confluence-server
    restart: always
    volumes:
      - /data/confluence:/var/atlassian/application-data/confluence
    ports:
      - 8090:8090
      - 8091:8091
  confl-mysql:
    build: ./mysql
    restart: always
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=yes
      - MYSQL_DATABASE=confluence
      - MYSQL_USER=confluence
      - MYSQL_PASSWORD=your-password

After hitting your-ip:8090 for the first time, you can pick the "My own database" option:

To connect to a MySQL db, you need to drop a MySQL JDBC driver into /opt/atlassian/confluence/confluence/WEB-INF/lib so at this point we've got a couple of options. We could either copy the JDBC driver into the container (but since containers are ephemeral we'd lose this change if we started a new container from the image), or take a step back and rebuild the image including the driver:

The right thing to do would be to rebuild a custom image including the driver. So let's do that.

Download the MySQL Connector driver from here.

Let's commit it into our project and add a new Dockerfile to build a modified version of the official Confluence image, which is simply just these two lines:

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

Update the docker-compose file to build this new image instead of using the provided one from Docker Hub. Replace:

image: atlassian/confluence-server

with

build: ./confl-mysql

(or your corresponding name of your custom image containing the above Dockerfile).

Now, when we startup this container and hit the app, the JDBC driver is recognized and we're on to the next config page for our database connection params:

Entering our credentials and pressing Test, we've got an error about the default encoding:

To address this, the Confluence setup docs, here, describe editing the my.cnf file in MySQL, or alternatively, I could pass params. The MySQL docs have a chapter on configuring and running MySQL in Docker, and this Q&A on Stackoverflow describes passing the optional params in a command section in your docker-compose file.

My first attempt was to add this:

confl-mysql:
  build: ./mysql
  restart: always
  command: character-set-server=utf8 collation-server=utf8_bin

but the syntax was not quite right yet, resulting in the container startup in a restart loop, and this error appeared in the container logs:

/usr/local/bin/docker-entrypoint.sh: line 202: exec: character-set-server=utf8: not found

Reading docs for the command option, the command in the docker-compose file needs to be the command to start the app in the container as well as the optional params. So now I'm here:

confl-mysql:
  build: ./mysql
  restart: always
  command: [mysqld, --character-set-server=utf8 --collation-server=utf8_bin]

Now we're getting closer. Logs from my MySQL container and how showing:

ERROR: mysqld failed while attempting to check config

command was: "mysqld --character-set-server=utf8 --collation-server=utf8_bin --verbose --help"

mysqld: Character set 'utf8 --collation-server=utf8_bin' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file

Some Googling made me realize each of the params is command separated, so next update is:

confl-mysql:
  build: ./mysql
  restart: always
  command: [mysqld, --character-set-server=utf8, --collation-server=utf8_bin]

Now we've got both containers starting up. The list of params should be updated to add all the optional params listed in the Confluence MySQL set up docs, otherwise, you'll get an error for each missing param. The complete list is:

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]

Now we're in business:

Complete config, and now the containers are up!

Docker (software) MySQL Confluence (software) Java Database Connectivity

Published at DZone with permission of Kevin Hooke, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Keep Your Application Secrets Secret
  • How to Run a MySQL Database in a Docker Container
  • Integrating Spring Boot Microservices With MySQL Container Using Docker Desktop
  • The Power of ShardingSphere With Spring Boot

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: