Docker create/start and --interactive option

  1. Is it correct to say that docker container create --interactive ubuntu is equal to docker container create -a STDIN -a STDOUT -a STDERR --interactive ubuntu?
  2. Is it correct to say that docker container start --interactive <container ID> is equal to docker container start --interactive --attach <container ID>?

I tested the following commands docker container create --interactive --name u8 ubuntu and docker container start --interactive u8 and I can properly interact with the bash shell.

You can check container configurations like this:

docker inspect --format '{{json .Config}}' <container name or id>

Replace <container name or id> with the name of a container or its id. You might want to pipe the result to jq to have a nice formatted output.

You can create all the variations you want, inspect their config and compare the resulting configs.

I am aware this does not directly answer your questions. It does something better: it shows you, how you can answer your questions yourself.

1 Like

I also had some tests here:

In short, -a or --attach means you attach to standard sreams which will happen by default unless passing -d or --detach, so yes to the question 1., but docker start or docker container start by default will not attach to STDIN as it also menitoned in the output of docker start --help

  -a, --attach               Attach STDOUT/STDERR and forward signals

But it is true, that @meyay gave you a way to check the config even if the behaviour changes in the future. Currently you can also use this command as well to get the the values of the relevant parameters:

docker inspect <container name or id> | grep -A5 AttachStdin

But it may not work in the future if the structure of the config changes.

Thanks both. Following your suggestions I can conclude that:

  1. docker container create --interactive is equal to docker container create -a STDIN -a STDOUT -a STDERR --interactive
  2. docker container start --interactive is not properly equal to docker container start --interactive --attach, since, as far as I understood, with docker container start --interactive STDOUT/STDERR is attached after sending the first input.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.