Elasticsearch startup fails if Bitbucket Server docker container is started as "root"

Still need help?

The Atlassian Community is here for you.

Ask the community



Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible


Problem

When a Bitbucket Server running as a docker container is started as root user (by modifying RUN_USER in Bitbucket Dockerfile), embedded Elasticsearch process fails to start.

The following appears in the atlassian-bitbucket.log

2021-03-17 02:58:15,188 DEBUG [pool-25-thread-1]  c.a.b.i.s.c.s.t.DefaultElasticsearchConnectionTester Testing connection with Elasticsearch failed due to exception: 
java.util.concurrent.CompletionException: java.net.ConnectException: Connection refused
        at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
        at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
        at java.util.concurrent.CompletableFuture.uniApply(Unknown Source)
        at java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
        at java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
        at java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)
        at com.atlassian.elasticsearch.client.apache.httpclient.ApacheRequestExecutor$1.failed(ApacheRequestExecutor.java:155)
        at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:138)
        at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.failed(AbstractClientExchangeHandler.java:414)
        at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.connectionRequestFailed(AbstractClientExchangeHandler.java:330)
        at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.access$100(AbstractClientExchangeHandler.java:61)
        at org.apache.http.impl.nio.client.AbstractClientExchangeHandler$1.failed(AbstractClientExchangeHandler.java:373)
        at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:138)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalPoolEntryCallback.failed(PoolingNHttpClientConnectionManager.java:503)
        at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:138)
        at org.apache.http.nio.pool.RouteSpecificPool.failed(RouteSpecificPool.java:163)
        at org.apache.http.nio.pool.AbstractNIOConnPool.requestFailed(AbstractNIOConnPool.java:542)
        at org.apache.http.nio.pool.AbstractNIOConnPool$InternalSessionRequestCallback.failed(AbstractNIOConnPool.java:817)
        at org.apache.http.impl.nio.reactor.SessionRequestImpl.failed(SessionRequestImpl.java:160)
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:173)
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:145)
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:191)
        at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:171)
        ... 5 common frames omitted

Diagnosis

Environment

Cause

Elasticsearch cannot be started as root.

Workaround

Modifle Bitbucket Dockerfile (or revert to its default version) and rebuild Bitbucket Server docker image.


DescriptionIf the RUN_USER environment variable in Bitbucket Dockerfile is set to root, the embedded Elasticsearch instance fails to start in the running container
ProductBitbucket
Last modified on Aug 25, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.