I need a help when I use 'exec' and ctrl+P+Q

When I use ubuntu in docker, I do that:

  1. run ‘docker run -it --name ubuntu ubuntu’. then install gcc and type ctrl+P+Q when compile my code.
  2. run ‘docker exec -it ubuntu /bin/bash’. then compile my another code and type ctrl+P+Q.
  3. run ‘docker exec -it ubuntu /bin/bash’. then do another things…
    now, how to get into 1st screen?