However If I start container as busybox /bin/sh
I see full result
[24] 1736
[]
Error: No such object: busybox.2022-09-04-10.28.29
[24]+ Stopped sudo docker run -it --name busybox.$(date +%Y-%m-%d-%H.%M.%S) busybox /bin/sh
But container is present in
sudo docker ps
I need to see container ID in the same terminal session for both type of container (daemon and interactive) - is it possible? Or I need to open another terminal session and monitoring result of
You should not use $(date +%Y-%m-%d-%H.%M.%S) multiple times, because the time between the two execution can change, so you will refer to a wrong container name.Save the result to a variable, and use the variable multiple times.
I am not sure if yoiu really wanted to do this: pwd & sudo docker ...
If you want to run your container in the background, you can just use the --detach or -d flag, but then you need to run a command in the container which keeps that container alive. pwd will not do that. Even if you try to send the container to the background, pwd will show you the output and stop so the container will stop immediately. If your command worked, I guess it ran so fast that the time did not change. Then you tried running a shell, which keeps the container alive when you use an interactive terminal (-it), so you can se a container running, but the time could change and this is not the same container you try to inspect.
If you run the container in the background, you will get the ID on the standard output: