docker exec : Execute commands in the running container OPTIONS description: -d : Split mode: running in the background -i : Keep STDIN open even if there is no attachment -t : Assign a pseudo terminal Execute the in-container / root/runoob.sh script in interactive mode in the container mynginx: Open an interactive mode terminal in the container mynginx: You can also use the docker ps-a command to see which containers are already running, and then use the container ID to enter the container. Check the container ID that is already running: The 9df70f9a0714 in the first column is the container ID. Bash the specified container through the exec command: 2.36.1. Grammar ¶
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
2.36.2. Example ¶
runoob@runoob:~$ docker exec -it mynginx /bin/sh /root/runoob.sh
http://www.runoob.com/
runoob@runoob:~$ docker exec -i -t mynginx /bin/bash
root@b1a0703e41e7:/#
# docker ps -a
...
9df70f9a0714 openjdk "/usercode/script.sh…"
...
# docker exec -it 9df70f9a0714 /bin/bash