1 00:00:00,001 --> 00:00:03,934 [No Audio] 2 00:00:03,934 --> 00:00:07,634 Just like previous demos, we have a list of container here. 3 00:00:07,634 --> 00:00:11,001 Now, let's use docker container attach command. 4 00:00:11,001 --> 00:00:13,379 It means that we are attaching the 5 00:00:13,379 --> 00:00:17,249 standard I/O and standard error of our container to 6 00:00:17,249 --> 00:00:19,767 the terminal of our Docker client. 7 00:00:20,367 --> 00:00:25,167 We have attached my busybox container here, so let's hit enter. 8 00:00:25,934 --> 00:00:28,349 As you can see, now we are accessing 9 00:00:28,349 --> 00:00:31,709 standard I/O or terminal of busybox from our 10 00:00:31,709 --> 00:00:36,209 Ubuntu terminal. If we hit ls, we will see a list 11 00:00:36,209 --> 00:00:39,701 of available directories in busybox root environment. 12 00:00:39,701 --> 00:00:41,639 We can play around a bit more to 13 00:00:41,639 --> 00:00:43,667 navigate to other directories as well. 14 00:00:43,667 --> 00:00:48,267 If we exit it, we return back to our Ubuntu host terminal. 15 00:00:48,667 --> 00:00:51,567 And there is an interesting aspect to the attach command. 16 00:00:51,567 --> 00:00:54,449 When we list the containers again, we can 17 00:00:54,449 --> 00:00:58,234 see that my-busybox container is not running, 18 00:00:58,234 --> 00:01:02,249 it has exited a few seconds ago. In other words, 19 00:01:02,249 --> 00:01:05,301 attaching the container conditions it to be 20 00:01:05,301 --> 00:01:08,034 stopped when we exit the attachment. 21 00:01:08,134 --> 00:01:11,901 An alternative to this is docker exec command, 22 00:01:11,901 --> 00:01:15,689 it allows us to use any command we want and it 23 00:01:15,689 --> 00:01:19,867 executes the container but before let's start our container again. 24 00:01:21,301 --> 00:01:23,519 Now we have used docker exec 25 00:01:23,519 --> 00:01:27,179 which stands for execute with -it flag and 26 00:01:27,179 --> 00:01:30,689 have directed it to run and print the result of 27 00:01:30,689 --> 00:01:35,567 pwd command. Once it succeeds, we have the 28 00:01:35,567 --> 00:01:38,601 '/', which indicates root of our busybox. 29 00:01:38,601 --> 00:01:41,867 Unlike attach, if we list the containers again, 30 00:01:41,867 --> 00:01:44,667 we'll find our containers still up and running.