docker exec -it <container name> /bin/bash
# to get the name of the existing container
$docker ps
# Command to get a bash shell in the container
$docker exec -it <container name> /bin/bash
# to execute whatever command you specify in the container.
docker exec -it <container name> <command> to execute whatever command you specify in the container.
docker exec --user root -it <container name> /bin/bash
docker exec <container name> bash -c printenv
sudo docker attach Container_Name
sudo docker exec –it nginx-test /bin/bash