Test:
# in terminal 1, run a service like a database
docker run --rm --name first postgres
# in terminal 2
cat <<EOF > docker-compose.yml
second:
image: busybox
external_links:
- first:uno
EOF
docker-compose run --rm second /bin/sh
Which will give you a BusyBox shell, and env
shows the UNO_*
env vars.
However, change the YAML to the following VALID YAML (e.g. try this linter or this one), and it will not work with docker-compose 1.5.1
(via DockerToolbox-1.9.1a.pkg
).
second:
image: busybox
external_links: {first: uno}
It is valid yaml, but it is not a valid Compose file. {}
is an object, not an array. You need:
second:
image: busybox
external_links: ['first:uno']
Obvious in retrospect, thanks!
@bfirsh just checking if a PR introducing this feature is a good idea or not: for keys that require an array (like external_links
), also get them to support an object.
This makes the YAML file clearer if one mostly has arrays of one item.
Before:
foo:
image: busybox
environment:
- "PORT:9000"
external_links:
- "bar:quux"
After:
foo:
image: busybox
environment: "PORT:9000"
external_links: "bar:quux"
It Worked for me when I updated the indentation and placed it inside an array.
ERROR:The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.mydb: 'MYSQL_ROOT_PASSWORD'
services.mydb.environment contains an invalid type, it should be an object, or an array
Unsupported config option for services.mydb: 'MYSQL_ROOT_PASSWORD
You are completely missing environment
@sreekanthdev
@OneCricketeer What does that even mean? I'm having the same problem but I don't understand your solution.
@Obinna5
services:
mydb:
image: mysql
environment: # this is an array
- MYSQL_ROOT_PASSWORD='password123'
I suggest you study what objects (or hashes) and arrays (or lists) mean in YAML
Most helpful comment
@Obinna5
I suggest you study what objects (or hashes) and arrays (or lists) mean in YAML