What's the docker-compose equivalent of docker run --init?
Asked Answered
L

2

61

According to https://github.com/krallin/tini#using-tini, tini is built into docker, and can be used by passing the --init flag to docker run. In my case I'm using docker-compose and don't invoke docker run directly. How can I pass this flag?

Leak answered 15/5, 2018 at 17:22 Comment(0)
B
38

If you are using version 2 of docker-compose, the configuration parameter is called init.

Example:

version: '2.2'
services:
  web:
    image: alpine:latest
    init: /usr/libexec/docker-init

Please see here for more details: https://docs.docker.com/compose/compose-file/compose-file-v2/#init

If you're using docker-compose version 3, apparently this has been removed and returned in version 3.7. Please refer to the following ticket: https://github.com/docker/docker.github.io/issues/3149

Bannasch answered 15/5, 2018 at 18:32 Comment(3)
Ah, ok. It was removed from version 3 but from that ticket it sounds like it is being worked on. At the moment, the takeaway is: "While the --init option is not yet supported for services, you can add the tini binary to your images (see the README for tini)."Leak
As of version 3.7, it's back. Just specify init: true for the appropriate service(s). (Requires Docker 18.06)Soothsay
Do you know how to set the verbose mode for this service ? is it via a global docker verbose setting i cant seem to be able to find ?Gunmaker
F
52

Here is an example from Docker Docs:

version: "2.4"
services:
  web:
    image: alpine:latest
    init: true
Ferrigno answered 16/10, 2020 at 19:1 Comment(0)
B
38

If you are using version 2 of docker-compose, the configuration parameter is called init.

Example:

version: '2.2'
services:
  web:
    image: alpine:latest
    init: /usr/libexec/docker-init

Please see here for more details: https://docs.docker.com/compose/compose-file/compose-file-v2/#init

If you're using docker-compose version 3, apparently this has been removed and returned in version 3.7. Please refer to the following ticket: https://github.com/docker/docker.github.io/issues/3149

Bannasch answered 15/5, 2018 at 18:32 Comment(3)
Ah, ok. It was removed from version 3 but from that ticket it sounds like it is being worked on. At the moment, the takeaway is: "While the --init option is not yet supported for services, you can add the tini binary to your images (see the README for tini)."Leak
As of version 3.7, it's back. Just specify init: true for the appropriate service(s). (Requires Docker 18.06)Soothsay
Do you know how to set the verbose mode for this service ? is it via a global docker verbose setting i cant seem to be able to find ?Gunmaker

© 2022 - 2024 — McMap. All rights reserved.