You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If both of the above scripts are present, they are executed in this order:
124
+
125
+
1.`init.sh`
126
+
2.`init.asadmin`
127
+
128
+
However, always consider to executing any asadmin configuration commands during build, because configuring the server at container startup will prolong the startup time.
129
+
130
+
### Execute asadmin commands before server startup
131
+
132
+
Just create a file `${PATH_GF_HOME}/custom/init.asadmin` (`/opt/glassfish7/custom/init.asadmin`), the commands will be executed before GlassFish server starts.
133
+
134
+
Within the `init.asadmin` file, you can specify any asadmin command. Most of the commands require that the server is running, so you'll need to start the server first, run the configuration commands, and then stop the server.
135
+
136
+
For example, to start GlassFish, increase the maximum amount of threads, and then stop it, the `init.asadmin` file can contain:
137
+
138
+
```
139
+
start-domain
140
+
set configs.config.server-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=1000
141
+
stop-domain
142
+
```
143
+
144
+
You can provide the file by mounting its directory to the `/opt/glassfish7/custom` directory in the container when running the container:
145
+
146
+
```
147
+
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti @docker.glassfish.repository@
148
+
```
149
+
150
+
### Execute a `bash` script before server startup
151
+
152
+
Just create a Bash script `${PATH_GF_HOME}/custom/init.sh` (`/opt/glassfish7/custom/init.sh`), it will be executed before GlassFish server starts.
153
+
154
+
Within the `init.sh` script, you can run any asadmin command, with `asadmin --interactive=false multimode COMMAND`. Most of the commands require that the server is running, so you'll need to start the server first, run the configuration commands, and then stop the server. If you need to run multiple commands, we recomment running asadmin commands in a single "multimode" asadmin execution to run them faster, with commands provided either on standard input or in a separate file via the `asadmin --interactive=false multimode -f` option.
155
+
156
+
----
157
+
158
+
**NOTE:** If you only need to execute `asadmin` commands before server startup, it's easier to use the init.asadmin script to execute them directly, without a `bash` script.
159
+
160
+
----
161
+
162
+
For example, to start GlassFish, increase the maximum amount of threads, and then stop it, the `init.sh` script can contain:
163
+
164
+
```
165
+
echo "start-domain
166
+
set configs.config.server-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=1000
167
+
stop-domain" | asadmin --interactive=false
168
+
```
169
+
170
+
You can provide the script by mounting its directory to the `/opt/glassfish7/custom` directory in the container when running the container:
171
+
172
+
```
173
+
docker run -v ./custom:/opt/glassfish7/custom -p 8080:8080 -ti @docker.glassfish.repository@
174
+
```
175
+
176
+
### Execute `asadmin` commands during Docker image build
177
+
178
+
Applying the configuration can be a lengthy operation. If you can configure the server during build time, it's recommended running asadmin configuration commands in a custom Docker image. This moves the configuration step to the image build time instead of runtime.
179
+
180
+
To do it, simply add `RUN instructions that run `asadmin` script with the usual arguments. For example, to move the example configuration from the `init.sh` script above to Dockerfile:
181
+
182
+
File `Dockerfile`:
183
+
184
+
```
185
+
FROM @docker.glassfish.repository@
186
+
187
+
RUN printf "start-domain \n \
188
+
set configs.config.server-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=1000 \n \
189
+
stop-domain" | asadmin --interactive=false
190
+
```
191
+
192
+
Or you can put the asadmin commands into a separate file and run it using `asadmin --interactive=false multimode -f`. For example:
193
+
194
+
File `commands.asadmin`:
195
+
196
+
```
197
+
start-domain
198
+
set configs.config.server-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=1000
199
+
stop-domain
200
+
```
201
+
202
+
File `Dockerfile`:
203
+
204
+
```
205
+
FROM @docker.glassfish.repository@
206
+
207
+
COPY commands.asadmin commands.asadmin
208
+
209
+
RUN asadmin --interactive=false multimode -f commands.asadmin
0 commit comments