init
works fine in version 2.2:
cat > docker-compose.yml <<EOF
version: '2.2'
services:
xyz:
image: alpine
command: sleep 5m
init: true
EOF
docker-compose up -d
init
fails in version 3.0:
cat > docker-compose.yml <<EOF
version: '3.0'
services:
xyz:
image: alpine
command: sleep 5m
init: true
EOF
docker-compose up -d
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.xyz: 'init'
This documentation:
https://docs.docker.com/compose/compose-file/compose-versioning/
reports that init
was introduced in version 2.2. There's no mention if it being removed.
Also tested with version 3.1, 3.2, and 3.3... init
fails in all of them
It wasn't removed from v3, it was never added to it in the first place.
Do you know why wasn't it added?
Because v3 is the format for creating Swarm services, and Swarm services do not support custom init
yet.
Because v3 is the format for creating Swarm services
That's news to me. I thought it was simply the sequel to v2, i.e. for the same purpose but also supporting additional stuff like swarms.
If v3 files are made for a different purpose than v2, that's not clear in the docs or anywhere else, at all. Shouldn't be docker-compose then, but rather swarm-compose or something, to make that diversion clearer.
This is not an acceptable explanation. There is no way to understand this from the documentation; the version matrix and upgrade instructions omit any mention of difference in purpose from the 2.x to 3.x lines. If what is explained here by @shin- is actually true, the docs must be updated.
This just bit me as well. Given v3 is now marked as current and recommended, it should document the init
removal there as well: https://docs.docker.com/compose/compose-file/compose-versioning/#version-3
"Add --init option to docker service create
" was recently merged.
Perhaps this issue should be reopened and changed from a question to a feature request for the (in progress) support for init
?
https://docs.docker.com/compose/compose-file/compose-versioning/
Version 3聽(most current, and recommended)
An unexpected description for a version that does not have the most current features.
As Sebastiaan pointed out, this will be available in the upcoming 3.7 format.
Most helpful comment
That's news to me. I thought it was simply the sequel to v2, i.e. for the same purpose but also supporting additional stuff like swarms.
If v3 files are made for a different purpose than v2, that's not clear in the docs or anywhere else, at all. Shouldn't be docker-compose then, but rather swarm-compose or something, to make that diversion clearer.