One of my containers needs to be run with -it
to work, is that possible to do in compose? I can’t find anything about it in the documentation.
Thanks in advance.
Share and learn in the Docker community.
One of my containers needs to be run with -it
to work, is that possible to do in compose? I can’t find anything about it in the documentation.
Thanks in advance.
-i
doesn’t really make sense with docker-compose up
(up
is a one-way command generally, not interactive, which either backgrounds or presents the pretty interlaced logs for the containers).
However you can use docker-compose run
which does -it
by default for the containers it runs (if I understand correctly).
For example:
$ docker-compose run --help
By default, linked services will be started, unless they are already
running. If you do not want to start linked services, use
`docker-compose run --no-deps SERVICE COMMAND [ARGS...]`.
Usage: run [options] [-p PORT...] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]
Options:
-d Detached mode: Run container in the background, print
new container name.
--name NAME Assign a name to the container
--entrypoint CMD Override the entrypoint of the image.
-e KEY=VAL Set an environment variable (can be used multiple times)
-u, --user="" Run as specified username or uid
--no-deps Don't start linked services.
--rm Remove container after run. Ignored in detached mode.
-p, --publish=[] Publish a container's port(s) to the host
--service-ports Run command with the service's ports enabled and mapped
to the host.
-T Disable pseudo-tty allocation. By default `docker-compose run`
allocates a TTY.
-w, --workdir="" Working directory inside the container