|
1 | 1 | # Oracle Management Agent Container Image
|
2 |
| -This repository contains sample container configurations to facilitate installation and environment setup for DevOps users. This project includes Dockerfiles based on Oracle Linux and Oracle OpenJDK 8. |
| 2 | + |
| 3 | +This repository contains sample container configurations of [Oracle Management Agent](https://docs.oracle.com/en-us/iaas/management-agents/index.html) to facilitate installation and environment setup for DevOps users. This project includes Dockerfiles based on Oracle Linux and Oracle OpenJDK 8. |
3 | 4 |
|
4 | 5 | The certification of Oracle Management Agent in a container does not require the use of any file presented in this
|
5 | 6 | repository. Customers and users are welcome to use them as starters, and customize/tweak, or create
|
6 | 7 | from scratch new scripts and Dockerfiles.
|
7 | 8 |
|
| 9 | +> Note: The Oracle Management Agent container image no longer requires elevated privileges. You can now chose to create a new user for the agent when building the image or at runtime by providing the UID and GID values of an existing user account on the host system. |
8 | 10 |
|
9 | 11 | ## How to build and run
|
10 | 12 |
|
11 |
| -Oracle Management Agent image uses the official `oraclelinux:7-slim` container image as the base image. |
| 13 | +Oracle Management Agent image uses the official `oraclelinux:8-slim` container image as the base image. |
12 | 14 |
|
13 |
| -#### Prerequisites |
| 15 | +## Prerequisites |
14 | 16 |
|
15 |
| -1. [Download the Management Agent software](https://cloud.oracle.com/macs) |
| 17 | +1. [Download the Oracle Management Agent software](https://cloud.oracle.com/macs) |
16 | 18 |
|
17 |
| - **Note: Select 'Downloads and Keys' then download 'Agent for LINUX (X86_64)' of the package type ZIP.** |
| 19 | + > Note: Select 'Downloads and Keys' then download 'Agent for LINUX (X86_64)' of the package type ZIP. |
18 | 20 |
|
19 |
| -1. Copy the downloaded bundle to the same directory as the Dockerfile |
| 21 | +1. Copy the downloaded bundle to the same directory as the `Dockerfile` |
20 | 22 |
|
21 | 23 | ```shell
|
22 |
| - $ cp oracle.mgmt_agent.zip OracleManagementAgent/dockerfiles/latest/ |
| 24 | + cp oracle.mgmt_agent.zip OracleManagementAgent/dockerfiles/latest/ |
23 | 25 | ```
|
24 | 26 |
|
25 |
| -1. Follow the steps in the [Create Install Key](https://docs.oracle.com/en-us/iaas/management-agents/doc/management-agents-administration-tasks.html#GUID-C841426A-2C32-4630-97B6-DF11F05D5712) and [Configure a Response File](https://docs.oracle.com/en-us/iaas/management-agents/doc/install-management-agent-chapter.html#GUID-5D20D4A7-616C-49EC-A994-DA383D172486) sections of the [Management Agent](https://docs.oracle.com/en-us/iaas/management-agents/index.html) documentation to create an install key and save it locally as `input.rsp`. |
| 27 | +1. Change to the directory in which the `Dockerfile` for this container image is located |
| 28 | + |
| 29 | + ```shell |
| 30 | + cd OracleManagementAgent/dockerfiles/latest/ |
| 31 | + ``` |
26 | 32 |
|
27 |
| -1. Copy the downloaded install key to the same directory as the Dockerfile |
| 33 | +1. Follow the steps in the [Create Install Key](https://docs.oracle.com/en-us/iaas/management-agents/doc/management-agents-administration-tasks.html#GUID-C841426A-2C32-4630-97B6-DF11F05D5712) documentation to download the install key. |
| 34 | +Next, follow the steps to [Configure a Response File](https://docs.oracle.com/en-us/iaas/management-agents/doc/install-management-agent-chapter.html#GUID-5D20D4A7-616C-49EC-A994-DA383D172486) and save it locally as `input.rsp` in the current directory. |
| 35 | + |
| 36 | +1. Create a directory on the host to store persisitent data. This directory will be bind mounted into the container at runtime. |
28 | 37 |
|
29 | 38 | ```shell
|
30 |
| - $ cp input.rsp OracleManagementAgent/dockerfiles/latest/ |
| 39 | + rm -rf /oracle-management-agent |
| 40 | + mkdir -p /oracle-management-agent |
31 | 41 | ```
|
32 | 42 |
|
33 |
| -1. Change to the directory in which the `Dockerfile` for this container image is located |
| 43 | +1. Create a local user account that will be used to run the container. This can be any user account on the host system and if the desired user already exists then this step can be skipped. |
| 44 | + |
| 45 | + ```shell |
| 46 | + groupadd -g 9100 orclmgmtagntgrp |
| 47 | + useradd orclmgmtagntusr -u 9200 -g 9100 -m -s /bin/bash |
| 48 | + ``` |
| 49 | + |
| 50 | + > Note: Remember to substitute `orclmgmtagntusr` and `orclmgmtagntgrp`, wherever applicable, with the desired user if you choose to skip this step. |
| 51 | + |
| 52 | +1. Change ownership of the directory holding persistent data to the desired user. |
34 | 53 |
|
35 | 54 | ```shell
|
36 |
| - $ cd OracleManagementAgent/dockerfiles/latest/ |
| 55 | + chown -R orclmgmtagntusr:orclmgmtagntgrp /oracle-management-agent |
37 | 56 | ```
|
38 | 57 |
|
39 | 58 | 1. Ensure your tenancy is configured correctly by [applying the documented prerequisites for deploying management agents](https://docs.oracle.com/en-us/iaas/management-agents/doc/perform-prerequisites-deploying-management-agents.html)
|
40 | 59 |
|
41 |
| -#### Steps to build and run using Docker Compose |
| 60 | +## Using Docker Compose |
| 61 | + |
| 62 | +1. Create .env file to populate the environment variables |
42 | 63 |
|
43 |
| -1. Create .env file to populate the hostname variable |
44 | 64 | ```shell
|
45 |
| - $ echo "mgmtagent_hostname=mgmtagent912" > .env |
| 65 | + echo "mgmtagent_hostname=mgmtagentcontainer1" > .env |
| 66 | + echo "DOCKER_BASE_DIR=/oracle-management-agent" >> .env |
| 67 | + echo "USERID=$(id -u orclmgmtagntusr)" >> .env |
| 68 | + echo "GROUPID=$(id -g orclmgmtagntusr)" >> .env |
46 | 69 | ```
|
47 |
| - **Note: Chose a unique hostname as it will be used to identify Management Agent in the UI.** |
48 | 70 |
|
49 | 71 | 1. Use Docker Compose CLI to build and run a container image
|
50 | 72 |
|
51 | 73 | ```shell
|
52 |
| - $ docker-compose up -d |
| 74 | + docker-compose up --build -d |
53 | 75 | ```
|
54 | 76 |
|
55 |
| -#### Steps to build and run using Docker CLI |
| 77 | +## Using Docker or Podman |
56 | 78 |
|
57 | 79 | 1. Build the container image
|
58 | 80 |
|
59 | 81 | ```shell
|
60 |
| - $ docker build -t oracle/mgmtagent-container . |
| 82 | + > docker build -t oracle/mgmtagent-container . |
61 | 83 | ```
|
62 | 84 |
|
63 |
| -1. Create a Docker volume to share configs with the container |
| 85 | +1. Copy the Install Key (`input.rsp`) into the directory that will be bind mounted into the container and used for persistent storage |
64 | 86 |
|
65 | 87 | ```shell
|
66 |
| - $ docker volume create mgmtagent-volume |
67 |
| -
|
68 |
| - # identify the mount point location to use in next steps |
69 |
| - $ docker volume inspect mgmtagent-volume|grep Mountpoint |
70 |
| - "Mountpoint": "/var/lib/docker/volumes/mgmtagent-volume/_data", |
| 88 | + mkdir -p /oracle-management-agent/mgmtagent_secret/ |
| 89 | + cp input.rsp /oracle-management-agent/mgmtagent_secret/ |
| 90 | + chown -R orclmgmtagntusr:orclmgmtagntgrp /oracle-management-agent/mgmtagent_secret/ |
71 | 91 | ```
|
72 | 92 |
|
73 |
| -1. Copy the Install Key (input.rsp) into the shared Docker volume Mountpoint |
| 93 | +1. Start a container |
74 | 94 |
|
75 | 95 | ```shell
|
76 |
| - # create any necessary dirs |
77 |
| - $ mkdir -p /var/lib/docker/volumes/mgmtagent-volume/_data/mgmtagent_secret |
78 |
| - $ cp input.rsp /var/lib/docker/volumes/mgmtagent-volume/_data/mgmtagent_secret/ |
| 96 | + # commands given below expect user to be running in a bash shell |
| 97 | + export USERID=$(id -u orclmgmtagntusr) |
| 98 | + export GROUPID=$(id -g orclmgmtagntusr) |
| 99 | + docker run --user $USERID:$GROUPID -d --name mgmtagentcontainer1 --hostname mgmtagentcontainer1 -v /oracle-management-agent/:/opt/oracle:rw --restart unless-stopped oracle/mgmtagent-container:latest |
79 | 100 | ```
|
80 | 101 |
|
81 |
| -1. Start a container |
| 102 | + > Note: Refer to [description of the recommended run parameters](https://docs.docker.com/engine/reference/run) used above |
| 103 | + |
| 104 | +1. Remove the Install Key (`input.rsp`) from the host directory after [verifying the new Oracle Management Agent is registered and visible in the main Oracle Management Agent page](https://docs.oracle.com/en-us/iaas/management-agents/doc/install-management-agent-chapter.html#GUID-46BE5661-012E-4557-B679-6456DBBEAA4A) |
82 | 105 |
|
83 | 106 | ```shell
|
84 |
| - $ docker run -d --name mgmtagent-container --hostname mgmtagent1 -v mgmtagent-volume:/opt/oracle:rw --restart unless-stopped oracle/mgmtagent-container:latest |
| 107 | + > rm /oracle-management-agent/mgmtagent_secret/input.rsp |
85 | 108 | ```
|
86 | 109 |
|
87 |
| - **Description of Docker run parameters used above** |
88 |
| - <!-- markdownlint-disable MD033 --> |
89 |
| - | Parameter | Description | |
90 |
| - | --------- | ----------- | |
91 |
| - | -d | Starts mgmtagent-container in detached mode | |
92 |
| - | --name mgmtagent-container | The name given to the container to identify it. | |
93 |
| - | --hostname mgmtagent1 | Assign mgmtagent1 as the containers internal hostname. This can be any hostname compliant string and it will be used to identify the Management Agent instance in the OMC Console. | |
94 |
| - | -v mgmtagent-volume | /opt/oracle:rw: Mounts the volume mgmtagent-volume created on host filesystem inside the container at /opt/oracle with Read/Write privileges. | |
95 |
| - | --restart unless-stopped | Unless explicitly stopped, this restart policy restarts mgmtagent-container automatically when docker restarts. | |
96 |
| - <!-- markdownlint-enable MD033 --> |
| 110 | +## Running custom user operations |
| 111 | + |
| 112 | +You can provide a custom shell script that will run before the Oracle Management Agent starts by following these steps |
97 | 113 |
|
98 |
| -1. Remove the Install Key (input.rsp) from the shared Docker volume Mountpoint after [verifying the new Management Agent is registered and visible in the main Management Agents page](https://docs.oracle.com/en-us/iaas/management-agents/doc/install-management-agent-chapter.html#GUID-46BE5661-012E-4557-B679-6456DBBEAA4A) |
| 114 | +1. Refer to [init-agent.sh](dockerfiles/latest/user-scripts/init-agent.sh) in the user-scripts directory |
| 115 | + |
| 116 | + Modify the script `init-agent.sh` to add custom commands that execute each time before Oracle Management Agent starts |
| 117 | + |
| 118 | +1. Follow the steps to build and run a container and validate the output of `init-agent.sh` script is visible in the logs by running the following command |
99 | 119 |
|
100 | 120 | ```shell
|
101 |
| - $ rm /var/lib/docker/volumes/mgmtagent-volume/_data/mgmtagent_secret/input.rsp |
| 121 | + > docker logs mgmtagent-container |
102 | 122 | ```
|
103 | 123 |
|
104 |
| -#### Steps to execute custom user operations |
| 124 | +## Troubleshooting |
105 | 125 |
|
106 |
| -Users can provide custom shell script commands to execute before starting Management Agent as described in the following steps |
| 126 | +Below are some possible solutions to common issues that may occur when running the Oracle Management Agent in a container |
107 | 127 |
|
108 |
| -1. Refer to [init-agent.sh](dockerfiles/latest/user-scripts/init-agent.sh) in the user-scripts directory |
| 128 | +1. mkdir: cannot create directory '/opt/oracle/bootstrap': Permission denied |
109 | 129 |
|
110 |
| - Modify the script `init-agent.sh` to add custom commands that execute each time before Management Agent starts |
| 130 | + * Ensure the mounted bind volume exists and is accessible by the user used to run the container |
| 131 | + * Verify the user USERID and GROUPID used match the permissions set on the mounted bind volume |
| 132 | + * Verify the mounted bind volume exists on the host |
111 | 133 |
|
112 |
| -1. Follow the steps to build and run a container and validate the output of `init-agent.sh` script is visible in the logs by running the following command |
| 134 | +1. Invalid argument: /opt/oracle/mgmtagent_secret/input.rsp |
| 135 | + |
| 136 | + * Ensure the install key exists at the required location |
| 137 | + |
| 138 | +1. Oracle Management Agent registration failures due to old state files from a prior install |
| 139 | + * Once a Oracle Management Agent instance is deregistered that instance must be shutdown and any associated state files must be removed from the filesystem. Starting a deregistered Oracle Management Agent instance again can result in unregistered agent failures. |
| 140 | + This situation can present itself when old state files from a prior installation are present on the filesystem and made available to a new Oracle Management Agent container deployment. Run the command given below on the host filesystem to perform the necessary cleanup on the bind mount location and perform the deployment again starting at the prerequisites step. |
113 | 141 |
|
114 | 142 | ```shell
|
115 |
| - $ docker logs mgmtagent-container |
| 143 | + rm -rf /oracle-management-agent/ |
116 | 144 | ```
|
117 | 145 |
|
118 |
| -#### Helpful administration commands |
| 146 | +## Helpful commands |
119 | 147 |
|
120 |
| -1. Starting a stopped Management Agent Container |
| 148 | +1. Starting a stopped Oracle Management Agent Container |
121 | 149 |
|
122 | 150 | ```shell
|
123 |
| - $ docker start mgmtagent-container |
| 151 | + docker start mgmtagent-container |
124 | 152 | ```
|
125 | 153 |
|
126 |
| -1. Stopping a running Management Agent Container |
| 154 | +1. Stopping a running Oracle Management Agent Container |
127 | 155 |
|
128 | 156 | ```shell
|
129 |
| - $ docker stop mgmtagent-container |
| 157 | + docker stop mgmtagent-container |
130 | 158 | ```
|
131 | 159 |
|
132 |
| -1. Inspecting logs of Management Agent Container |
| 160 | +1. Inspecting the logs of a running Oracle Management Agent container |
133 | 161 |
|
134 | 162 | ```shell
|
135 |
| - $ docker logs mgmtagent-container |
| 163 | + docker logs mgmtagent-container |
136 | 164 | ```
|
137 | 165 |
|
138 |
| -1. Cleanup volume using Docker Compose |
| 166 | +1. Gathering UID and GID of a user from the host environment |
139 | 167 |
|
140 | 168 | ```shell
|
141 |
| - $ docker-compose down --volumes |
| 169 | + id -u <username> # prints UID of user |
| 170 | + id -g <username> # prints GID of user |
142 | 171 | ```
|
143 | 172 |
|
144 |
| -1. Cleanup volume using Docker CLI |
| 173 | +1. Creating a nominated user account during image development (optional) |
145 | 174 |
|
146 | 175 | ```shell
|
147 |
| - $ docker volume rm mgmtagent-volume |
| 176 | + groupadd -g <numeric-gid-value> <desired-groupname> |
| 177 | + # example: |
| 178 | + groupadd -g 9100 orclmgmtagntgrp |
| 179 | +
|
| 180 | + useradd <desired-username> -u <numeric-uid-value> -g <numeric-gid-value> -m -s /bin/bash |
| 181 | + # example: |
| 182 | + useradd orclmgmtagntusr -u 9200 -g 9100 -m -s /bin/bash |
| 183 | +
|
| 184 | + # Tip: Add useradd/groupadd to Dockerfile to create a nominated user during image development |
148 | 185 | ```
|
149 | 186 |
|
| 187 | +## Container Files for Older Releases |
| 188 | + |
| 189 | +The Oracle Management Agent older container files mentioned below are no longer actively maintained and they are kept in this repository for historical purposes only. |
| 190 | + |
| 191 | +* Oracle Management Agent container files version 1.0.0 [`docker-images/OracleManagementAgent/dockerfiles/1.0.0`](./dockerfiles/1.0.0) |
| 192 | + |
| 193 | +**Notes:** |
| 194 | + |
| 195 | +* Oracle Management Agent container files version 1.0.0 require elevated privileges to run and therefore are not compatible with the latest version found in this repository. Upgrading a version 1.0.0 container to run with the latest container files is also not supported for the same reason. |
| 196 | + |
150 | 197 | ## License
|
| 198 | + |
151 | 199 | 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.
|
152 | 200 |
|
153 | 201 | Oracle Linux is licensed under the [Oracle Linux End-User License Agreement](https://oss.oracle.com/ol/EULA).
|
154 | 202 |
|
155 |
| -All scripts and files hosted in this project and GitHub [`docker-images/OracleManagementAgent`](./) repository, required to build the Docker images are, unless otherwise noted, released under the [UPL 1.0](https://oss.oracle.com/licenses/upl/) license. |
| 203 | +All scripts and files hosted in this project and GitHub [`docker-images/OracleManagementAgent`](./) repository, required to build the container images are, unless otherwise noted, released under the [UPL 1.0](https://oss.oracle.com/licenses/upl/) license. |
156 | 204 |
|
157 | 205 | ## Support
|
| 206 | + |
158 | 207 | Oracle Management Agent container image is supported for the Linux images listed [here](https://docs.oracle.com/en-us/iaas/management-agents/doc/perform-prerequisites-deploying-management-agents.html#GUID-BC5862F0-3E68-4096-B18E-C4462BC76271). For more details please see My Oracle Support.
|
159 | 208 |
|
160 | 209 | ## Copyright
|
161 |
| -Copyright (c) 2022 Oracle and/or its affiliates. |
| 210 | + |
| 211 | +Copyright (c) 2022, 2023 Oracle and/or its affiliates. |
0 commit comments