Executing a command
Executing a command within a Docker container can be done in two different ways. Either directly, or interactively.
If you want to do it directly, you use the following syntax. I will explain it with the ls
command as an example.
docker exec <container> ls
If you want to do it interactively, you need to use the -it
tag and specify which shell, in this case bash
.
docker exec -it <container> bash
This will allow you to “enter” the container and use it as if you were SSH:ing into it.