It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Running Atlassian server product on Docker

Atlassian server products can be installed using a Docker image as well as an installer running directly on your OS.
Official docker image for Jira is published in Atlassian repository in Docker hub, so I will introduce some tips to use Atlassian server products using Docker.

Objectives

The objectives of this article are

  • Starting up Jira, Confluence and Bitbucket on your client machine using Docker

  • Installing each single product

  • Setting up integrations between products

Note, I keep configuration as simple as possible, therefore it's not suitable for production environment. For example, some requirements like data persistence or SSL is not supported on the configuration in this article.
Also, I won't consider connecting via SSH to Bitbucket because it's not necessary for the objective of this article.

 

Prerequisite

Install Docker on your machine. It may be better allocating enough memory for Docker when you boot multiple containers. I confirmed steps in this article with the following environment.

  • Docker Desktop 2.1.0.3 on macOS Mojave (7 GB memory allocated for Docker)

  • Jira 8.4.0

  • Confluence 7.0.1

  • Bitbucket 6.6.1

Installing and setting up each product

Jira Software

1. Open terminal and hit following command


docker run -d -p 8080:8080 atlassian/jira-software:latest

2. Open following URL with your browser
http://localhost:8080

Confluence

1. Open terminal and hit following command

docker run -d -p 8090:8090 atlassian/confluence-server:latest

2. Open following URL with your browser
http://localhost:8090

Bitbucket

1. Open terminal and hit following command

docker run -d -p 7990:7990 atlassian/bitbucket-server:latest

2. Open following URL with your browser
http://localhost:8090

 

You've done! Services run inside container by docker run command, and start listening on each port, so you can go to setup page.
In this step, proceed to evaluation setup choosing embedded database.

 

Setting up integration of products

Above step is quite simple if you want to try using single product, but it's not sufficient if you wanted to try integrations of each products.
That is why each container that is running services doesn't belong to same network and can't communicate each other.
There would be several ways to let each container communicate. Here, I'll introduce a way to boot multiple containers in a same network utilizing docker-compose.

 

Requirement

You can try using integration functionalities by fulfilling following requirements at least.

  • Each service in containers can communicate each other

  • Name of each service is resolved by a unique URL

Note about second one. Most of Atlassian product have a configuration named "Base URL" as a unique service URL. Although you can configure multiple URLs for your instances as described in How to create an unproxied application link , it would be more straightforward if you configured as your browser and each product access using unique URLs for each services.
I will show you an example that each service is accessed via following URLs

See following diagram to figure out a network configuration.

docker-compose-sample-en.png

 

Steps

1. First, your client computer has to allow you to access to itself looping back your requests via the above URL.
Easiest way to achieve this is just to add records in your hosts file.

127.0.0.1 jira.internal
127.0.0.1 confluence.internal
127.0.0.1 bitbucket.internal

Otherwise, you can configure local DNS using dnsmasq and letting your client computer to resolve above name as 127.0.0.1.

2. Create following two files and put them on any new directory.

docker-compose.yaml

version: '3' 
services:
jira:
container_name: jira
image: atlassian/jira-software:latest
environment:
- ATL_PROXY_NAME=jira.internal
- ATL_PROXY_PORT=80
- ATL_TOMCAT_SCHEME=http

confluence:
container_name: confluence
image: atlassian/confluence-server:latest
environment:
- ATL_PROXY_NAME=confluence.internal
- ATL_PROXY_PORT=80
- ATL_TOMCAT_SCHEME=http

bitbucket:
container_name: bitbucket
image: atlassian/bitbucket-server:latest
environment:
- SERVER_PROXY_NAME=bitbucket.internal
- SERVER_PROXY_PORT=80
- SERVER_SCHEME=http

nginx:
container_name: nginx
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- jira
- confluence
- bitbucket
ports:
- "80:80"
networks:
default:
aliases:
- jira.internal
- confluence.internal
- bitbucket.internal

nginx.conf

events {} 
http {
server {
server_name jira.internal;
proxy_read_timeout 600s;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://jira:8080;
client_max_body_size 10M;
}
}
server {
server_name confluence.internal;
proxy_read_timeout 600s;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://confluence:8090;
client_max_body_size 10M;
}
}
server {
server_name bitbucket.internal;
proxy_read_timeout 600s;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://bitbucket:7990;
client_max_body_size 10M;
}
}
}

 

3. Now you are ready! Run following command and boot containers.

docker-compose up -d

 

4. Open "Application Link" page in Jira

https://confluence.atlassian.com/adminjiraserver/using-applinks-to-link-to-other-applications-938846918.html

Create application link for Confluence and Bitbucket.

Now you can use functionalities like Jira Issue Macro or Smart Commit

 

Troubleshooting

Each Docker container consumes about 2GB so some container may not boot properly if memory is not allocated enough.

You can configure memory allocation setting as https://docs.docker.com/config/containers/resource_constraints/ 

 

Note

In this article I introduced steps to install Atlassian product with simple configuration and this won't be suitable for production environment. But you will be able to configure to work on your production environment. Please refer to the following documentations for detailed specification.

 

 

16 comments

This article needs a bit more on how to access these in my network.

I'm not running on localhost but in a private network like most users. What URL would I use? what about finishing the setup? Connecting to the database?

This article is not finished...

Follow up...

OK, I got thrown by the 127.0.0.1 settings in Hosts.

What this should say is to define the entries in the hosts file as

<serverIP> jira.internal

THEN it's fully correct. My server within my home network is at 192.168.1.2, so all the Docker apps would be accessible from 192.168.1.2. Only use 127.0.0.1 if you are installing this on a machine with a graphical system and you are actually logged in on, such as your laptop.

As far as finishing up, all the apps operate as normal, requesting setup if required. What I don't know is what happens if I re-run the docker-compose with my existing database, i.e. an upgrade...

 

Have to take a look at how that all unfolds. If I'm lucky, if will see the file that shows the settings and recognize the DB...

Hi @rene_robinson, great to hear that you utilize my article to run on your environment. 

You are right, use 127.0.0.1 only when you want to run on your client machine for the evaluation. And tweaking hosts file would be the most handy way to resolve the name jira.internal  to point 192.168.1.2. Otherwise setting up a DNS server would be suitable option for larger network. 

As for

What I don't know is what happens if I re-run the docker-compose with my existing database, i.e. an upgrade...

You can use Docker volume for data persistence. It will keep your database even when you recreated containers. 

Hope this helps :)

Nobuyuki, Thanks for the follow up. I did set up a volume and will have to test the persistence. 

One more thing, you may need to increase the 10M on Nginx to 100M if you want to post anything larger than 10M, like photos, etc. Found out when trying to add pictures to confluence. 

Thanks for the help. 

Hi

 

First of all thanks for this post, It's being really useful to me. 

I'm getting an error with the gadgets URL. 

I've added to my host:

127.0.0.1 jiralocal.com

 Then, in docker compose file jira container: 

jira:
image: atlassian/jira-software
networks:      
- jiranet
ports:      
- "8080:8080"
environment:
- "ATL_PROXY_NAME=jiralocal.com"
       - "ATL_PROXY_PORT=80"
       - "ATL_TOMCAT_SCHEME=http"
       - "ATL_TOMCAT_CONTEXTPATH=/jira"

 And Nginx container on Docker compose:

nginx:
image: nginx:latest
volumes:      
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- jira
ports:
80:80
networks:
- jiranet

And then I have the nginx.conf file like this:

events {}
http {
server {
server_name jiralocal.com;
proxy_read_timeout 600s;
location /jira {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://jira:8080/jira;
client_max_body_size 10M;
}
}
}

 

I can access jira on http://jiralocal.com/jira without any extrange problem, but gadgets return 

gadget.common.error.500 and URL base is set to the URL I use to access. 

In the logs the error is:

2020-03-24 13:53:17,080+0000 HealthCheck:thread-4 ERROR [c.a.t.j.healthcheck.support.GadgetFeedUrlHealthCheck] An error occurred when performing the Gadget feed URL healthcheck
org.apache.http.conn.HttpHostConnectException: Connect to jiralocal.com:80 [jiralocal.com/127.0.0.1] failed: Connection refused (Connection refused)

I'm running this on W10

Can anyone help me with this? 

Hi @Jorge_Jerez , thank you for your comment! 

It seems you encountered Jira activity stream gadget throws gadget.common.error.500 . Jira has to be able to access to itself by base url.

In your case, apparently the request to jiralocal.com is looping back to Jira container itself as it is resolved as 127.0.0.1. You will have to configure your network to let  jiralocal.com be resolved as the nginx container because 80 port is exposed only on the nginx.

I think adding an alias to jiralocal.com in the nginx container will do the trick.   

  nginx: 
....
networks:
default:
aliases:
- jiralocal.com

 Hope this helps. 

Hi @Nobuyuki Mukai

Thanks for your comment, yesterday I tested that way and worked for me, I'm new on Docker so I have a lot of thing to learn. 

 

Anyway, some people with experience in Docker ask me to use Traefic instead of Nginx or Apache, because work better on Docker, do you know something about this?

Hi, @Jorge_Jerez , Great to hear that worked in your environment :)

And as for traefik, yes, I believe it can be an alternative to Nginx. I've used traefik before for testing purpose, and it was working fine as far as I tested. Also I found someone who configures traefik with Atlassian products --

@Nobuyuki Mukai As I understood application links are using O-Auth authentification to establish the link. Even though: is there a possibility to preconfigure application links in the docker-compose file (maybe by providing credentials for a admin user account, which should be created on startup)?

hi @Tobi_P , unfortunately, the Atlassian's docker images don't support the configuration to the application link. 

Though this is unofficial and I cannot guarantee that it will work, the workaround in https://jira.atlassian.com/browse/JRASERVER-61753 may help the automation of the application link creation process. Please vote if this feature request interests you. 

Hi @Nobuyuki Mukai 

Thanks for this great article. I had this idea for a long time and then with the help of your article finally implemented it. Our DEV and TEST environments for Jira and Confluence are running on Docker now since almost a half year. We have done some further configuration and described it here:

http://coffeetime.solutions/run-atlassian-jira-and-confluence-with-postgresql-on-docker/

Thank you very much! 

Hi @andybandy89 

Thanks for your comment! I'm happy to hear that my article helped you :)

Thanks @Nobuyuki Mukai

This is really helpful while setting up jira ,confluence on a same platform.

However i was facing issue while running docker-compose up -d

Error:

Status: Downloaded newer image for nginx:latest

Creating jira ... done

Creating confluence ... done

Creating bitbucket ... done

Creating nginx ... error


ERROR: for nginx Cannot create container for service nginx: status code not OK but 500: {"Message":"Unhandled exception: Filesharing has been cancelled","StackTrace":" at Docker.ApiServices.Mounting.FileSharing.<DoShareAsync>d__6.MoveNext() in C:\\workspaces\\stable-2.3.x\\src\\github.com\\docker\\pinata\\win\\src\\Docker.ApiServices\\Mounting\\FileSharing.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n

P.S. I have updated the c and d drive as well in file sharing. please suggest.

Hi @aarti rajput 

It sounds like you are facing https://stackoverflow.com/questions/60754297/docker-compose-failed-to-build-filesharing-has-been-cancelled . Did you restart Docker for Windows after updating the file sharing section?

Thanks for Reply @Nobuyuki Mukai .

But File sharing is already enabled and docker is restarted also. its working if i commented volumed section in docker-compose.yml.

with mounted volume its not working

nginx: container_name:

nginx image: nginx:latest

volumes:

- ./nginx.conf:/etc/nginx/nginx.conf

depends_on: - jira

@aarti rajput 

It sounds like a problem of Docker for Windows or Windows OS itself. Do you use the latest version of the Docker? 

Otherwise you may be able to avoid the usage of mounted volume for nginx by tweaking the compose file a bit.

For example, change the nginx section of docker-compose.yaml to build from docker file

nginx:
container_name: nginx
build:
context: .
dockerfile: nginxdockerfile
ports:
- "80:80"
....

and locate a file nginxdockerfile in a same directory.

FROM nginx:latest
COPY ./nginx.conf /etc/nginx/nginx.conf

That will create a nginx container which already includes nginx.conf without using mounted volume.  

Comment

Log in or Sign up to comment
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you