Host: Centos 7
Docker version: 19.03.12, build 48a66213fe
Docker compose version: version 1.26.2, build eefe0d31
I am using the advice given here on specifying environment variables in the shell and then passing those into the compose file. So my docker-compose
file looks like this:
version: '3.8'
services:
springboot:
image: <my image>
ports:
- "8445:8445"
depends_on:
- "database"
environment:
- SPRING_PROFILES_ACTIVE=dev
database:
image: "mongo"
Here’s the error that I’ve run into:
ERROR: for 39b165c237b9_deploy_springboot_1 Cannot create container for service springboot: invalid volume specification: 'a9d7debde5ffcba2a023c12d5f1e822567e9b4047a1bda76efeefbfc80c1f622:app/data:rw': invalid mount config for type "volume": invalid mount path: 'app/data' mount path must be absolute
The corresponding Docker file does have a reference to VOLUME app/data
, however that doesn’t seem controversial.
If I take out the environment
block, it seems to work fine (though the application starts without having the right config, but at least it doesn’t error).
So what is the right way to pass on shell environment variables to the container?
EDIT
Thanks to @David Maze, it was indeed the VOLUME declaration in the original Docker file – nothing to do with docker-compose
. Deleted it and it now works. Thanks!
2
Answers
there are 2 ways to specify directories in docker.
Try replacing
SPRING_PROFILES_ACTIVE=dev
bySPRING_PROFILES_ACTIVE: dev
Instead, so replace=
with:
. And you should also add thevolume
to thedocker-compose
file:And according the error message, the path must be absolute.