I've used docker run -it
to launch containers interactively and docker run -d
to start them in background. These two options seemed exclusive. However, now I've noticed that docker run -dit
(or docker run -itd
) is quite common. So what is the difference? When -it
is really needed together with -d
?
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
Yes, sometimes, it's necessary to include
-it
even you-d
When the
ENTRYPOINT
isbash
orsh
docker run -d ubuntu:14.04
will immediately stop, causebash
can't find any pseudo terminal to be allocated. You have to specify-it
so thatbash
orsh
can be allocated to a pseudo terminal.If you want to use
nano
with any container in the future, you have to specify-it
when the image starts. Otherwise you'll get error. For example,It will throw an error
Error opening terminal: unknown.