Problem with running docker-compose.yml
My docker-compose.yml:
services:
sharry:
image: eikek0/sharry:latest
container_name: sharry
command: /opt/sharry.conf
ports:
- "9090:9090"
volumes:
- ./sharry.conf:/opt/sharry.conf
depends_on:
- db
networks:
- intranet
db:
image: postgres:16.3
container_name: postgres_db
volumes:
- ./postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=dbuser
- POSTGRES_PASSWORD=dbpass
- POSTGRES_DB=dbname
networks:
intranet:
external: true
The according error:
root@stormy /opt/docker-compose/sharry # docker compose up
[+] Running 2/0
✔ Container postgres_db Created 0.0s
✔ Container sharry Created 0.0s
Attaching to postgres_db, sharry
postgres_db |
postgres_db | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_db |
postgres_db | 2024-07-01 11:13:26.169 UTC [1] LOG: starting PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
postgres_db | 2024-07-01 11:13:26.170 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_db | 2024-07-01 11:13:26.170 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_db | 2024-07-01 11:13:26.173 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_db | 2024-07-01 11:13:26.180 UTC [28] LOG: database system was shut down at 2024-07-01 09:25:29 UTC
postgres_db | 2024-07-01 11:13:26.190 UTC [1] LOG: database system is ready to accept connections
sharry | 2024.07.01 11:13:27:615 io-compute-3 INFO sharry.restserver.Main.run:54
sharry | Using given config file: /opt/sharry.conf
sharry | Exception in thread "io-compute-3" java.lang.ExceptionInInitializerError
sharry | at sharry.restserver.config.ConfigFile$.loadConfig(ConfigFile.scala:8)
sharry | at sharry.restserver.Main$.run$$anonfun$2(Main.scala:63)
sharry | at cats.effect.IOFiber.runLoop(IOFiber.scala:413)
sharry | at cats.effect.IOFiber.execR(IOFiber.scala:1362)
sharry | at cats.effect.IOFiber.run(IOFiber.scala:112)
sharry | at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:702)
sharry | Caused by: com.typesafe.config.ConfigException$IO: /opt/sharry.conf: java.io.FileNotFoundException: /opt/sharry.conf (Is a directory)
sharry | at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:190)
sharry | at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:174)
sharry | at com.typesafe.config.impl.Parseable.parse(Parseable.java:301)
sharry | at com.typesafe.config.ConfigFactory.parseFile(ConfigFactory.java:793)
sharry | at com.typesafe.config.ConfigFactory.parseApplicationReplacement(ConfigFactory.java:1166)
sharry | at com.typesafe.config.DefaultConfigLoadingStrategy.parseApplicationConfig(DefaultConfigLoadingStrategy.java:11)
sharry | at com.typesafe.config.ConfigFactory.defaultApplication(ConfigFactory.java:532)
sharry | at com.typesafe.config.ConfigFactory$1.call(ConfigFactory.java:264)
sharry | at com.typesafe.config.ConfigFactory$1.call(ConfigFactory.java:261)
sharry | at com.typesafe.config.impl.ConfigImpl$LoaderCache.getOrElseUpdate(ConfigImpl.java:66)
sharry | at com.typesafe.config.impl.ConfigImpl.computeCachedConfig(ConfigImpl.java:93)
sharry | at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:261)
sharry | at com.typesafe.config.ConfigFactory.load(ConfigFactory.java:237)
sharry | at sharry.restserver.config.Hocon$.at(Hocon.scala:24)
sharry | at sharry.restserver.config.ConfigValues$.<clinit>(ConfigValues.scala:31)
sharry | ... 6 more
sharry | Caused by: java.io.FileNotFoundException: /opt/sharry.conf (Is a directory)
sharry | at java.base/java.io.FileInputStream.open0(Native Method)
sharry | at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
sharry | at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
sharry | at com.typesafe.config.impl.Parseable$ParseableFile.reader(Parseable.java:629)
sharry | at com.typesafe.config.impl.Parseable.reader(Parseable.java:99)
sharry | at com.typesafe.config.impl.Parseable.rawParseValue(Parseable.java:233)
sharry | at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:180)
sharry | ... 20 more
sharry | java.lang.ExceptionInInitializerError
sharry | at sharry.restserver.config.ConfigFile$.loadConfig(ConfigFile.scala:8)
sharry | at sharry.restserver.Main$.run$$anonfun$2(Main.scala:63)
sharry | at cats.effect.IOFiber.runLoop(IOFiber.scala:413)
sharry | at cats.effect.IOFiber.execR(IOFiber.scala:1362)
sharry | at cats.effect.IOFiber.run(IOFiber.scala:112)
sharry | at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:702)
sharry | Caused by: com.typesafe.config.ConfigException$IO: /opt/sharry.conf: java.io.FileNotFoundException: /opt/sharry.conf (Is a directory)
sharry | at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:190)
sharry | at com.typesafe.config.impl.Parseable.parseValue(Parseable.java:174)
sharry | at com.typesafe.config.impl.Parseable.parse(Parseable.java:301)
sharry | at com.typesafe.config.ConfigFactory.parseFile(ConfigFactory.java:793)
sharry | at com.typesafe.config.ConfigFactory.parseApplicationReplacement(ConfigFactory.java:1166)
sharry | at com.typesafe.config.DefaultConfigLoadingStrategy.parseApplicationConfig(DefaultConfigLoadingStrategy.java:11)
sharry | at com.typesafe.config.ConfigFactory.defaultApplication(ConfigFactory.java:532)
sharry | at com.typesafe.config.ConfigFactory$1.call(ConfigFactory.java:264)
sharry | at com.typesafe.config.ConfigFactory$1.call(ConfigFactory.java:261)
sharry | at com.typesafe.config.impl.ConfigImpl$LoaderCache.getOrElseUpdate(ConfigImpl.java:66)
sharry | at com.typesafe.config.impl.ConfigImpl.computeCachedConfig(ConfigImpl.java:93)
sharry exited with code 1
It looks like your ./sharry.conf doesn't exist or is a directory?
I changed the docker-compose a little but and created the the sharry.conf
docker-compose.yml:
services:
sharry:
image: eikek0/sharry:latest
container_name: sharry
command: /opt/docker-compose/sharry/sharry.conf
ports:
- "9090:9090"
volumes:
- ${PWD}/sharry.conf:/opt/sharry.conf
depends_on:
- db
networks:
- intranet
db:
image: postgres:16.3
container_name: postgres_db
volumes:
- ./postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=dbuser
- POSTGRES_PASSWORD=dbpass
- POSTGRES_DB=dbname
networks:
intranet:
external: true
I'm not sure what to say - does it work now or is the error the same? If so, I guess it is still the same problem. If you like to pass a config file, it must exist and mounted to some location in the container and then this location (in the container) must be added as an argument in the command:. I assume the location /opt/docker-compose/sharry/sharry.conf doesn't exist in the container?
Yes sorry, I forgot to mention that its still the same problem.
So I am in the shown directory and there is a
sharry.conf.
How can I check if the location /opt/docker-compose/sharry/sharry.conf exist in the container?
For example you could use docker run -it … I think and then check. So this line
volumes:
- ${PWD}/sharry.conf:/opt/sharry.conf
mounts your local file into the container at path /opt/sharry.conf. Then you need to specify this path. There are also docs about docker-compose explaining volumes (here for example).
I fixed it now. It turned out that sharry.conf is a directory, so I created a file and now the error wont occur anymore. Thanks for your help!
Nice! Correct, the sharry.conf is the config file. I'll then close this.