Bamboo remote agent 5.13.0.1 not working inside alpine 3.4 docker container
Asked by Laurent POCHON:

Hi,

I try to setup a bamboo remote agent on alpine 3.4 docker container.

It is working perfectly in my centos:7 container, but i can not make it work inside my alipine container.

The master is working perfectly inside alpine container, but i have some problems with the remote agents.

Here is my error :

Running \[/opt/atlassian/bamboo-agent-home/bin/bamboo-agent.sh, console\]  
Agent process started, shutdown hook registered, proceeding with log pump...  
Running Bamboo Agent...  
"/opt/atlassian/bamboo-agent-home/bin/./wrapper" "/opt/atlassian/bamboo-agent-home/bin/../conf/wrapper.conf" wrapper.syslog.ident=bamboo-agent wrapper.pidfile="/opt/atlassian/bamboo-agent-home/bin/./bamboo-agent.pid" wrapper.lockfile="/var/lock/subsys/bamboo-agent"  
/opt/atlassian/bamboo-agent-home/bin/bamboo-agent.sh: eval: line 1: /opt/atlassian/bamboo-agent-home/bin/./wrapper: not found  
Waiting for the agent process to finish...  
Underlying agent process has terminated cleanly,  
Bamboo Agent Installer is shutting down, the underlying agent process has already been shut down.

the failing command is : /opt/atlassian/bamboo-agent-home/bin/./wrapper /opt/atlassian/bamboo-agent-home/bin/../conf/wrapper.conf wrapper.syslog.ident=bamboo-agent wrapper.pidfile="/opt/atlassian/bamboo-agent-home/bin/./bamboo-agent.pid" wrapper.lockfile="/var/lock/subsys/bamboo-agent"

Here is a view of my file system :

[bamboo-remote-agent-a1:/opt/atlassian/bamboo-agent-home/bin#](http://bamboo-remote-agent-a1/opt/atlassian/bamboo-agent-home/bin) ll /opt/atlassian/bamboo-agent-home/bin/./wrapper  
-rwxr-xr-x 1 root root 117740 Sep 30 09:28 /opt/atlassian/bamboo-agent-home/bin/./wrapper

[bamboo-remote-agent-a1:/opt/atlassian/bamboo-agent-home/bin#](http://bamboo-remote-agent-a1/opt/atlassian/bamboo-agent-home/bin) ll /opt/atlassian/bamboo-agent-home/bin/../conf/wrapper.conf  
-rw-r--r-- 1 root root 2466 Sep 30 09:28 /opt/atlassian/bamboo-agent-home/bin/../conf/wrapper.conf

[bamboo-remote-agent-a1:/opt/atlassian/bamboo-agent-home/bin#](http://bamboo-remote-agent-a1/opt/atlassian/bamboo-agent-home/bin) ll /opt/atlassian/bamboo-agent-home/bin/  
total 132  
-rwxr-xr-x 1 root root 15102 Sep 30 09:48 bamboo-agent.sh  
-rwxr-xr-x 1 root root 117740 Sep 30 09:28 wrapper

[bamboo-remote-agent-a1:/opt/atlassian/bamboo-agent-home/bin#](http://bamboo-remote-agent-a1/opt/atlassian/bamboo-agent-home/bin) ll /var/lock/subsys/  
total 0

Here is the Dockerfile

# Use alpine version which is really lighter  
FROM openjdk:8-alpine

ENV BAMBOO_JAR_PATH /opt/atlassian/atlassian-bamboo-agent-installer-5.13.0.1.jar

# Setup some evironnement variables  
ENV container docker

# Upgrade alpine  
RUN apk -U upgrade  
# Add packages  
RUN echo "<http://dl-4.alpinelinux.org/alpine/edge/testing>" \>\> /etc/apk/repositories \&\& \\  
apk --update add \\  
iputils \\  
bash \\  
vim \\  
curl \\  
wget \\  
make \\  
git \\  
tomcat-native \\  
gzip \\  
php5 \\  
php5-cli \\  
php5-common \\  
php5-fpm \\  
php5-gd \\  
php5-imap \\  
php5-intl \\  
php5-mcrypt \\  
php5-mysqli \\  
php5-opcache \\  
php5-pgsql \\  
php5-soap \\  
php5-xml \\  
\&\& rm -rf /var/cache/apk/\*

# Install bamboo remote agent  
RUN mkdir /opt \&\& mkdir /opt/atlassian  
ADD conf${BAMBOO_JAR_PATH} ${BAMBOO_JAR_PATH}

CMD java -Dbamboo.home=/opt/atlassian/bamboo-agent-home/ -jar ${BAMBOO_JAR_PATH} <http://bamboo-master:8085/agentServer/>

Any idea ? Is the wrapper working with Alpine ?


Answers:
author: Przemek Bruski
body: Alpine is most likely missing the dl libs required to run the wrapper. I don't think there's a workaround, you should use the agent without the wrapper.

comments: author: Przemek Bruski
body: Something like that should work:

```
java -classpath bamboo-agent-bootstrap.jar? com.atlassian.bamboo.agent.bootstrap.AgentBootstrap http://localhost:8085/bamboo/agentServer
```


author: Dave Chevell
body: I did some research into this, and [@Przemek Bruski](/t5/user/viewprofilepage/user-id/781481) 100% right: Alpine swaps out glibc for musl libc, and the wrapper is dynamically linked against glibc libraries. You can see this in Alpine by running ldd against the wrapper:

```
bash-4.3# ldd bin/wrapper
 /lib64/ld-linux-x86-64.so.2 (0x55e5f5866000)
 libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x55e5f5866000)
 libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x55e5f5866000)
 libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x55e5f5866000)
Error relocating bin/wrapper: __fprintf_chk: symbol not found
Error relocating bin/wrapper: __printf_chk: symbol not found
Error relocating bin/wrapper: __memcpy_chk: symbol not found
Error relocating bin/wrapper: __vsnprintf_chk: symbol not found
Error relocating bin/wrapper: __read_chk: symbol not found
Error relocating bin/wrapper: __strcpy_chk: symbol not found
Error relocating bin/wrapper: __syslog_chk: symbol not found
Error relocating bin/wrapper: __sprintf_chk: symbol not found
Error relocating bin/wrapper: __realpath_chk: symbol not found
```

If you want to use the wrapper, the solution is to install glibc into your Alpine container. For example:

```
RUN apk --no-cache add ca-certificates \
 && wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub \
 && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk \
 && apk add glibc-2.25-r0.apk
```

(The above was found in <https://github.com/sgerrand/alpine-pkg-glibc>)

I maintain my own Bamboo agent Docker image: <https://bitbucket.org/dchevell/docker-bamboo-base-agent/overview> and I've just switched it to Alpine, and ran into the same issue. Making the above change resolved the issue and added about 10MB to the size of the image (uncompressed).

Please note: whilst I work for Atlassian support, the above is just a personal repo intended for illustration purposes and is not official or supported in any way.


Tags: bamboo-administration