[No Audio]
Just like previous demos, we have a list of container here.
Now, let's use docker container attach command.
It means that we are attaching the
standard I/O and standard error of our container to
the terminal of our Docker client.
We have attached my busybox container here, so let's hit enter.
As you can see, now we are accessing
standard I/O or terminal of busybox from our
Ubuntu terminal. If we hit ls, we will see a list
of available directories in busybox root environment.
We can play around a bit more to
navigate to other directories as well.
If we exit it, we return back to our Ubuntu host terminal.
And there is an interesting aspect to the attach command.
When we list the containers again, we can
see that my-busybox container is not running,
it has exited a few seconds ago. In other words,
attaching the container conditions it to be
stopped when we exit the attachment.
An alternative to this is docker exec command,
it allows us to use any command we want and it
executes the container but before let's start our container again.
Now we have used docker exec
which stands for execute with -it flag and
have directed it to run and print the result of
pwd command. Once it succeeds, we have the
'/', which indicates root of our busybox.
Unlike attach, if we list the containers again,
we'll find our containers still up and running.