Deploy SingleAgent in a Docker Container

Step 1: Add the following packages to include the apk command if the Docker container is running on Alpine OS.

curl, vim, unzip, bash, wget

Example:

RUN apk add --no-cache \
openjdk8-jre \
wkhtmltopdf \
aws-cli \
busybox-extras \
curl \
vim \
wget \
bash \
unzip \
tzdata && cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime && echo 'Asia/Kolkata' > /etc/timezone

Step 2: Create a file named startAgent.sh with the following content in the directory containing the Dockerfile.

#!/bin/sh

SERVER_NAME=`hostname`_sa
export SERVER_NAME

ARCTURUS_HOME=/usr/local/Applicare
export ARCTURUS_HOME

JAVA_HOME_PATH=$JAVA_HOME

INBUILD_JAVA_PATH=$ARCTURUS_HOME/jre
export INBUILD_JAVA_PATH

if [[ $(uname -s) == "Darwin" ]]; then
JAVA_HOME_PATH="$ARCTURUS_HOME/jre/mac/zulu-8_jre/Contents/Home"
else
JAVA_HOME_PATH="$ARCTURUS_HOME/jre/linux/jre"
fi

JAVA_HOME_PATH="/usr/lib/jvm/java-1.8-openjdk/jre"
export JAVA_HOME_PATH

JAVA_OPTS="-noverify -Xmx1024m -Dserver.name=$SERVER_NAME -javaagent:$ARCTURUS_HOME/applicare-db-aspects.jar=verbosity=0,logfile=false,norestart-intellitrace=false -Darcturus_home=$ARCTURUS_HOME -XX:HeapDumpPath=/dev/null -Djava.library.path=.:$ARCTURUS_HOME/bin -Dapplicare.standalone=true"
export JAVA_OPTS

EXECUTABLE_NAME=/usr/local/Applicare/AgentStartHelper.jar
export EXECUTABLE_NAME

# Run the JAR file
/usr/lib/jvm/java-1.8-openjdk/jre/bin/java -jar $JAVA_OPTS $EXECUTABLE_NAME

Step 3: Add the following line in the Dockerfile immediately after the package installation commands.

# Create working directory for Applicare
RUN mkdir -p /usr/local/Applicare

# Download and unzip Applicare
RUN curl CONTROLLER_PROTOCOL://CONTROLLER_IP:CONTROLLER_PORT/applicare/standalone?filename=ApplicareSingleAgentLinux.zip -o /usr/local/Applicare/ApplicareSingleAgentLinux.zip
RUN unzip /usr/local/Applicare/ApplicareSingleAgentLinux.zip -d /usr/local/Applicare

# Clean up
RUN rm -fv /usr/local/Applicare/ApplicareSingleAgentLinux.zip
RUN rm -fv /usr/local/Applicare/agentscripts/startAgent.sh

# Copy the start script
COPY startAgent.sh /usr/local/Applicare/agentscripts/startAgent.sh
RUN chmod -R 777 /usr/local/Applicare

Replace the below values in the above command

CONTROLLER_PROTOCOL -> http (or) https

CONTROLLER_IP -> Applicare Controller IP

CONTROLLER_PORT -> Applicare Controller Port

Step 4: Comment out the existing CMD line in the Dockerfile and replace it with the following CMD line.

CMD ["/bin/sh", "-c", "nohup /usr/local/Applicare/agentscripts/startAgent.sh & java -jar /usr/local/rest-TestApplication.jar"]

After starting the agent using the provided CMD command, it will operate similarly to running a Java application. If you need to run a different application, you can remove the current command and replace it with the appropriate command to start your desired application.

Step 5: Add and execute the following command before starting the container.

--hostname <Server_Name>

e.g.
docker run -dit -p 8086:8080 --name restapi --hostname dev c9700fdfc2f5

The hostname you specify will be displayed on the overview screen in Applicare.

You can use Applicare to assist with your Monitoring needs.

Monitoring with Applicare

Was this article helpful?

Votes and follows are kept by Zendesk, so they need a Help Center account. These buttons open this article there.

Opens Zendesk · needs internet and sign-in

Still stuck? Contact support