docs
docs copied to clipboard
Why use the -itd options instead of -d in the docker run command?
Is this a docs issue?
- [x] My issue is about the documentation content or website
Type of issue
Information is incorrect
Description
Here are the results of the three options running separately
-itmeans will start an interactive session that can execute commands inside the container and interact with the output of the container.-dmeans running the container in the background,and print container's id.-itdwii be like-d,not achieving the effect of-it.
So,why use the -itd options instead of -d in the docker run command? Is it something I missed out on, or is it a mistake in the document?
Location
https://docs.docker.com/reference/cli/docker/container/run/#:~:text=docker%20run%20%2Ditd%20%2D%2Dnetwork%3Dmy%2Dnet%20busybox
Suggestion
If it's a mistake,I'd be happy to open a PR to fix it.
-itd keeps the container running in the background by attaching a tty to it. This lets you docker container exec into the container. Without -t, the container would exit immediately after starting up, since there's on process to keep it running. -i is optional but makes the container read from stdin if you attach to it.
I guess these flags are used in the example just to keep the container running, and to let you exec or inspect the container after it was created to verify that it's running on the my-net network. I agree that we should explain this clearly...
If you/anyone would like to work on this, the source file that needs updating lives in a different repository, here: https://github.com/docker/cli/blob/master/docs/reference/commandline/container_run.md#network
There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.
Prevent issues from auto-closing with a /lifecycle frozen comment.
/lifecycle stale
There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.
Prevent issues from auto-closing with a /lifecycle frozen comment.
/lifecycle stale
Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.
If you have found a problem that seems similar to this, please open a new issue.
/lifecycle locked