While container developing or deploying we often need to look inside a running container to examine its current state or correct a problem. For this, Docker provides the docker exec command to run programs in containers that are already running.
The command started using docker exec only runs while the container's primary process. Any command executed inside the container will run in the default working directory.

The syntax of the Docker exec command is -

docker container exec -it [CONTAINER_ID] OR [CONTAINER_NAME] /bin/sh

Example: 

$ docker container exec -t df148cbe0b29 sh