Skip to content

Commit 96e536d

Browse files
authored
Oracle Management Agent in a Container - support agent run as root user (#2403)
1 parent 07f4c72 commit 96e536d

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

OracleManagementAgent/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,27 @@ Oracle Management Agent image uses the official `oraclelinux:7-slim` container i
101101
$ rm /var/lib/docker/volumes/mgmtagent-volume/_data/mgmtagent_secret/input.rsp
102102
```
103103

104+
#### Steps to run Management Agent as root user
105+
106+
Management Agent can be run as the root user if access to specific locations (example: `/var/log`) within the container environment are restricted to only the root user as described in the following steps. Please also note that the steps given below must be applied prior to container creation. Applying these changes after creating the container is not supported.
107+
108+
##### Steps to run as root when using Docker Compose
109+
110+
1. Update the .env file to override the agent run-as-user environment variable
111+
```shell
112+
$ echo "RUN_AGENT_AS_USER=root" >> .env
113+
```
114+
**Note: Modifying this environment variable after container creation is not supported. Refer to volume cleanup in Helpful administration commands section and then startover.**
115+
116+
##### Steps to run as root when using Docker CLI
117+
118+
1. Start a container overriding the agent run-as-user environment variable
119+
```shell
120+
$ docker run -d --env RUN_AGENT_AS_USER=root --name mgmtagent-container --hostname mgmtagent1 -v mgmtagent-volume:/opt/oracle:rw --restart unless-stopped oracle/mgmtagent-container:latest
121+
```
122+
**Note: Setting this environment variable after container creation is not supported. Refer to volume cleanup in Helpful administration commands section and then startover.**
123+
124+
104125
#### Steps to execute custom user operations
105126

106127
Users can provide custom shell script commands to execute before starting Management Agent as described in the following steps
@@ -135,6 +156,18 @@ Users can provide custom shell script commands to execute before starting Manage
135156
$ docker logs mgmtagent-container
136157
```
137158

159+
1. Cleanup volume using Docker Compose
160+
161+
```shell
162+
$ docker-compose down --volumes
163+
```
164+
165+
1. Cleanup volume using Docker CLI
166+
167+
```shell
168+
$ docker volume rm mgmtagent-volume
169+
```
170+
138171
## License
139172
To download and run the Oracle Management Agent, regardless whether inside or outside a container, you must download the binaries from the Oracle website and accept the license indicated at that page.
140173

OracleManagementAgent/dockerfiles/latest/container-scripts/watchdog.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ BOOTSTRAP_HOME=/opt/oracle-mgmtagent-bootstrap
1414
SCRIPTS=$BOOTSTRAP_HOME/scripts
1515
PACKAGES=$BOOTSTRAP_HOME/packages
1616
UPGRADE_STAGE=$BOOTSTRAP_HOME/upgrade
17-
RUN_AGENT_AS_USER=mgmt_agent
1817
CONFIG_FILE=/opt/oracle/mgmtagent_secret/input.rsp
1918
MGMTAGENT_HOME=/opt/oracle/mgmt_agent
2019
AUTOUPGRADE_BUNDLE=$MGMTAGENT_HOME/zip/oracle.mgmt_agent-??????.????.linux.zip
@@ -30,6 +29,13 @@ echo $$ > /var/run/mgmtagent_watchdog.pid
3029
trap "log 'Stopping container ...'; stop_agent; exit" SIGINT SIGTERM
3130

3231

32+
###########################################################
33+
# Init environment
34+
if [[ -z "$RUN_AGENT_AS_USER" ]]; then
35+
export RUN_AGENT_AS_USER="mgmt_agent"
36+
fi
37+
38+
3339
###########################################################
3440
# Check if agent upgrade is available
3541
# Returns: 0 if upgrade exists otherwise 1

OracleManagementAgent/dockerfiles/latest/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ services:
2626
# Image name reported by docker images listing
2727
image: oracle/mgmtagent-container
2828

29+
environment:
30+
RUN_AGENT_AS_USER: ${RUN_AGENT_AS_USER:-mgmt_agent}
31+
2932
# Internal hostname identifier for the container
3033
hostname: ${mgmtagent_hostname}
3134

0 commit comments

Comments
 (0)