Reputation: 928
I am new to Docker. I was trying to implement MySQL using Docker container.
When it comes to executing mysql command in Docker container, the tutorial shows this command docker exec -it mysql1 mysql -uroot -p
Docker document mentioned docker exec
means run a command in container .
The optional i
tag means "Keep STDIN open even if not attached" .
The optional t
tag means "allocate a pseudo tty" .
What means "Keep STDIN open", what means "attached"?
What means "allocate a pseudo tty"?
I'm not familiar with shell commands. I don't know why '-it' should be added here.
Will it be different if I just type docker exec mysql1 mysql -uroot -p
?
So confused, looking forward to any help... thanks...
Upvotes: 12
Views: 6438
Reputation: 2908
Will Cain's answer is more complete, but in short, giving -it
lets you get inside the container in interactive mode i.e -
-t
: Allocate a pseudo-tty
-i
: Keep STDIN open even if not attached
Docs for docker run that explains those arguements.
NOTE: docer exec
is for running a command inside an already running container. Hence it is extremely useful for debugging conatiners.
Upvotes: 1
Reputation: 7057
-i
-- Don't just run the program in the background with no way to send it data; keep it open to accepting input of some form.
-t
-- Specifically, give me a place to type commands to send to the program, as if I had an ssh or telnet session open to a remote machine I could feed commands to.
Together they essentially make it so that you can run e.g. your mysql1
program as if you were just running it normally locally, outside a Docker container.
Upvotes: 18