In last section we learned about the importance of the Dash 80 flag in this section.
I want to tell you about one last use of the docker exact command and this use of it is probably going
to be the most common that you're going to be making use of on your own personal projects.
A very common thing that you're going to want to do when you are using Docker is to get shell access
or terminal access to your running container.
In other words you are going to want to run commands inside of your container without having to rerun
it Docker exact Docker exact Docker exact again and again all day.
So in this section I'm going to show you how you can open up a shell or terminal in the context of your
running container.
So here's what we're gonna do.
I'm going to put back over to my terminal.
I'm going to verify that I'm still running that Rudd bread is container.
I'm going to open up a second terminal window inside of here.
I'm going to run Docker P.S. and get my container I.D. and then I'm going to run a docker exec dash
I.T. I'll put the container I.D. in and then here's the magic I'm going to put in S H.
We'll talk about what s h is in just a second.
I'm going to run that command and you'll see that I get the little LB over here once I'm in here.
I can now start to type out typical commands that I would expect to be able to run in a UNIX environment.
So for example I could change my directory to my home directory.
I can list out the files and folders inside there.
Nothing there right now.
Let's try going back to the root directory of Slash.
And then if I do an L S I'll see all the root files and folders of the container I could execute commands
like Echo Hi there I can export variables environment variables like export B equals 5 and then echo
that.
So essentially when I make use of this Docker exact command with s h over here I get full terminal access
inside the context of the container which is extremely powerful for debugging I could even do things
like say run the docker CLIA directly or not Docker see all CLIA but read a c a lie and that starts
up the red a c a lie and then when I'm all done I can hit control C and it looks like nothing's happening
so quick shortcut here.
If you ever are in a container and it feels like you can't hit control C to exit you can always try
and command d to me control D to get out as well.
All right so let's talk about what just happened there.
So we ran Docker exact which we've seen several times before.
And then we did S H.
So what is S H S H is the name of a program and it's a program that has been executed inside that container.
S H is a command processor or a shell.
It's something that allows us to type commands in and have them be executed inside that container.
You are already making use of a program very much like a search on your own computer.
Chances are if you're on Mac OS you are probably using something like bash if you're on Windows you're
probably using something like get bash or power show.
Me personally I'm making use of Z shell.
These are all programs that allow you to type commands into your terminal and have them be executed.
And so when we start up SDH inside of our container that's just another command shell that we can use
to execute commands.
Traditionally a lot of the different containers that you're going to be working with are probably going
to have the same each command or suite or something DSH program all ready included some more complete
versions of containers or images are going to also have the bash command processor as well.
So in some cases you can make use of batch directly in vast majority you're probably going to be able
to run the shell inside there to start up a command prompt and type in some commands.
OK.
So again I think that you're probably going to be using Docker exact dash I.T. with s h as the command.
Mm.
Very very often when you start doing your own Docker development.
All right.
So we've spoken a whole bunch around Docker Seelye.
Let's take one more break here.
There's just one or two quick topics I want to talk about and we'll start to move on to our next big
topic.