I haven't posted on SO in a long while, I hope I am not breaking any rules.
I have an environment variable in my ~/.bash_profile exported as below and I made sure to run source ~/.bash_profile:
export HOSTNAME=some-name
And this is how my docker-compose.yml looks like:
version: '3'
services:
    someservice:
        build:
            context: .
            dockerfile: ./Dockerfile
        image: ...
        container_name: ...
        restart: unless-stopped
        hostname: "someservice.${HOSTNAME:?Error: env var HOSTNAME is not defined or is empty}"
        ...
If I run docker-compose up -d, I will get the following error:
ERROR: Invalid interpolation format for "hostname" option in service "some-service":
 "someservice.${HOSTNAME:?Error: env var HOSTNAME is not defined or is empty}"
If I replace HOSTNAME above with some-name, I will get the following error:
Starting someservice ... error
ERROR: for someservice  Cannot start service: OCI runtime create failed: 
container_linux.go:346: starting container process caused "process_linux.go:449: 
container init caused \"sethostname: invalid argument\"": unknown
ERROR: Encountered errors while bringing up the project.
Any idea why I am getting the error and how to troubleshoot and/or fix it? Thank you so much!
Edit1: Fixed typo in my export
Edit2: This might help with troubleshooting: Removing the ERROR part from the yaml file fixed the issue. So, in my docker-compose.yml I just have:
...
   hostname: "someservice.${HOSTNAME} 
...
 
     
    