docs icon indicating copy to clipboard operation
docs copied to clipboard

Why use the -itd options instead of -d in the docker run command?

Open nelvko opened this issue 1 year ago • 3 comments
trafficstars

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

  • -it means will start an interactive session that can execute commands inside the container and interact with the output of the container.
  • -d means running the container in the background,and print container's id.
  • -itd wii 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.

nelvko avatar Mar 27 '24 11:03 nelvko

-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...

dvdksn avatar Apr 02 '24 14:04 dvdksn

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

dvdksn avatar Apr 02 '24 15:04 dvdksn

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

docker-robot[bot] avatar Jul 01 '24 01:07 docker-robot[bot]

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

docker-robot[bot] avatar Oct 01 '24 01:10 docker-robot[bot]

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

docker-robot[bot] avatar Nov 14 '24 03:11 docker-robot[bot]