How can I set a Payara servers jvm-option in docker compose?
For the application I use the payara/server-full:5.194 container.
I know that I have to use the JVM_ARGS ENV Variable, but I don't know how exactly.
This is a piece of my docker-compose.yml file:
version: "3.5"
services:
myApplication:
build:
context: .
dockerfile: Dockerfile
image: myApplication:latest
environment:
POSTBOOT_COMMANDS: /tmp/init_asadmin_commands.sh
JVM_ARGS: -DmyApplication.home.dir=/msc/srv/myApplication
ports:
- "8080:8080"
- "4848:4848"
Does anybody has an example for me? (I haven't found a good usage)
Thanks!
Edit(1):
This is the error what i get on docker-compse up:
sed: -e expression #1, char 54: unknown option to `s'
And this is what I found, how the container uses it:
COMMAND=`echo "$OUTPUT"\
| sed -n -e '2,/^$/p'\
| sed 's/glassfish.jar/glassfish.jar '"$JVM_ARGS"'/' `
Related
I often need to start Odoo server with different arguments.
So in docker-compose.yml, which is versioned, I specified the following:
version: '3'
services:
web:
image: odoo:12.0
command: odoo ${ODOO_ARGS}
and created a .env file with:
ODOO_ARGS="--update=all"
This works well with a single argument, but it doesn't handle multiple arguments. For example if I try the following:
ODOO_ARGS="--database=myDb --update=all --stop-after-init"
the command will be evaluated as: odoo --database="myDb --update=all --stop-after-init"
I pretty sure it is a syntax issue, so I'd like to know how to pass multiple arguments to the command option through .env file.
It actually evaluates to odoo "--database=myDb --update=all --stop-after-init" just because you put quotes in the env file. Here is an example with several arguments in one string:
docker-compose.yml
version: "3.7"
services:
test:
image: debian:buster
command: find ${ARGS}
.env
ARGS=/ -name bash
Running this you'll get:
test_1 | /bin/bash
test_1 | /usr/share/lintian/overrides/bash
test_1 | /usr/share/menu/bash
test_1 | /usr/share/doc/bash
I try to get the ports from the services I defined in the compose_file.yml
as i need to to extract the ports docker generate me.
no option to inject them to docker .
version: '3.3'
services:
oracleTest:
image: ora_image
container_name: "test1"
ports:
- 15211:1521
mysqlTest:
image: mysql:8.0
container_name: "test2"
restart: always
ports:
- 33061:3306
what I found is that I can get the ports by container name , this is not what I need
I can get the services with :
docker-compose ps --services
also can cat the mapped port with docker command again not what I need
docker port mysql8.0 | cut -d':' -f 2
what I need is something like this pseudo code:
docker-compose -f compose_file.yml port oracleTest
or any think like this ... any idea?
If you want ports to be access explicitly anyway, then you might want to inject the port into docker-compose.yml file vie environment variables.
Say you have .env file (default for docker-compose to look up) as follow
oraclePort=15211
mysqlPort=33061
you can then edit your docker-compose.yml to accept variable as
version: '3.3'
services:
oracleTest:
image: ora_image
container_name: "test1"
ports:
-$oraclePort:1521 #<-- notice the variable
mysqlTest:
image: mysql:8.0
container_name: "test2"
restart: always
ports:
-$mysqlPort:3306 #<-- notice the variable
hope this is what you need.
Since docker-compose.yml is a regular YAML file, you can use yq as YAML shell parser.
kislyuk/yq: Command-line YAML and XML processor - jq wrapper for YAML/XML documents
Command-line YAML and XML processor - jq wrapper for YAML/XML documents https://kislyuk.github.io/yq/
install yq and jq
pip install yq
pip install jq
Parse ports from docker-compose.yml
cat docker-compose.yml | yq '.services|.[].ports'
[
"15211:1521"
]
[
"33061:3306"
]
Get ports of oracleTest
what i need is something like this pseudo code:
docker-compose -f compose_file.yml port oracleTest
To get ports of specific service, use:
cat docker-compose.yml | yq '.services.oracleTest.ports'
[
"15211:1521"
]
Following these instructions, I tried setting an environment variable with -e TC=3 and in the compose file like so:
services:
balancer:
environment:
- TC=3
But the variable is not set when the container is run.
Does anyone see what I'm doing wrong?
I'm using:
docker-compose 1.23.1, build b02f1306
Docker 18.06.1-ce, build e68fc7a
The way you are setting the environment is correct. With this compose file
version: '2'
services:
test:
environment:
- HELLO=WORLD
image: alpine
command: env
I got this output
$ docker-compose -f test-compose.yml up
Creating network "sandbox_default" with the default driver
Creating sandbox_test_1 ... done
Attaching to sandbox_test_1
test_1 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
test_1 | HOSTNAME=e2eb1a0da23e
test_1 | HELLO=WORLD
test_1 | HOME=/root
sandbox_test_1 exited with code 0
If you want to be able to override a variable written in compose file, then you need to use ${var_name} syntax, e.g.
environment:
- HELLO=${hello_value}
I have a .env file like below:
# DEV
SALES_DB_HOST=xxx
Then I have a docker-compose.yml file that looks like:
version: "3.1"
services:
web:
image: xxx
build: .
env_file: .env
However, the values for the environment variables when accessed in nodejs like process.env.SALES_DB_HOST it prints undefined.
Output of docker-compose config is:
services:
web:
build:
context: xxxxxxxx
environment:
SALES_DB_HOST: xxx
image: xxxxx
version: '3.1'
So, it looks like docker-compose.yml is formed correctly. But why is process.env not getting this value correctly?
EDIT:
I build the docker image with: docker build -t my_image .
Can you change command on you container configuration in yml file.
You should try to test your environment to understand - where is a problem. In docker or in your code.
Try something like this:
maxantonov : ~/passbolt .$ cat dc.yml
version: '3.4'
services:
db:
image: alpine:latest
container_name: db
hostname: db
env_file:
- env/mysql.env
command: ["printenv"]
maxantonov : ~/passbolt .$ docker-compose -f dc.yml up
Starting db ... done
Attaching to db
db | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
db | HOSTNAME=db
db | MYSQL_ROOT_PASSWORD=test
db | MYSQL_DATABASE=passbolt
db | MYSQL_USER=passbolt
db | MYSQL_PASSWORD=P4ssb0lt
db | HOME=/root
db exited with code 0
It's not a docker problem.
Look to your code:
process.env.process.env.SALES_DB_HOST
It's typo. process.env.process.env
You shold use
process.env.SALES_DB_HOST
I'm having problems with starting my containers via docker-compose up.
I guess this is an Windows problem, because my colleague owns a macbook and has now problems when he runs docker-compose up.
ERROR: for oracle-apex Cannot start service oracle-apex: oci runtime
error: container_linux.go:265: starting container process caused
"exec: \"/temp/entrypoint.sh\": stat /temp/entrypoint.sh: no such file
or directory"
The directory docker/apex/scripts does exists on my machine, isn't empty and contains the file entrypoint.sh.
I've found some similar problems when I've googled for this error, which told me to create a env file with COMPOSE_CONVERT_WINDOWS_PATHS=1, what I've done.
Versions:
Docker version 1.13.1, build 092cba3
docker-compose version 1.8.0,build unknown
Windows 10
docker-compose.yml
version: '2'
services:
proxy:
build: ./docker/proxy/
container_name: searchkit_proxy
ports:
- "8000:80"
volumes:
- ./docker/searchkit-v2/dist:/public/static
oracle-apex:
image: araczkowski/oracle-apex-ords
container_name: vanditmar-apex
volumes:
- ./docker/apex/scripts/:/temp/
ports:
- "49160:22"
- "8080:8080"
- "1521:1521"
entrypoint: ["/temp/entrypoint.sh"]
volumes:
esdata1:
driver: local
oracle-data:
driver: local
networks:
esnet:
Dockerfile in folder docker/apex/
FROM araczkowski/oracle-apex-ords
ADD ./scripts/ /temp/
RUN /temp/install.sh
entrypoint.sh
#!/bin/bash
exec >> >(tee -ai /docker_log.txt)
exec 2>&1
# # Update hostname
sed -i -E "s/HOST = [^)]+/HOST = $HOSTNAME/g" /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
sed -i -E "s/HOST = [^)]+/HOST = $HOSTNAME/g" /u01/app/oracle/product/11.2.0/xe/network/admin/tnsnames.ora
sed -i -E "s/PORT = [^)]+/PORT = 1521/g" /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
#
/etc/init.d/oracle-xe start
/etc/init.d/tomcat start
/etc/init.d/ssh start
/temp/install.sh
##
## Workaround for graceful shutdown. ....ing oracle... ‿( ́ ̵ _-`)‿
##
while [ "$END" == '' ]; do
sleep 1
trap "/etc/init.d/oracle-xe stop && END=1" INT TERM
done
;;
I'm new to docker, but I would like to know how to fix this problem. We think the problem is that the paths to the files are different on windows.
I use Bash on Ubuntu on Windows as command line. If there is any information missing please tell me, so I can add it :)