say if we are running the below command

docker run -it ubuntu:v1 /bin/bash

this will run the container and you are into the shell. But usually containers run other processes like apache / redis or any other process. So it wont be a shell always. But still if you want to connect / attach to the container inside of the shell, then there are various approaches

say if we are running below command, we created a container running the ping command as PID1. now comne out of it CTRL + P + Q.

docker run -it ubuntu:v1 /bin/bash -c "ping"

root@ubuntu14-04:/home/kmaringanti# docker run -it ubuntu:v1 /bin/bash -c "ping"
PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=53 time=24.8 ms
64 bytes from ( icmp_seq=2 ttl=53 time=35.9 ms
64 bytes from ( icmp_seq=3 ttl=53 time=23.3 ms
64 bytes from ( icmp_seq=4 ttl=53 time=22.2 ms
64 bytes from ( icmp_seq=5 ttl=53 time=22.0 ms

check in process list

root@ubuntu14-04:/home/kmaringanti# docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
41a0577aba34        ubuntu:v1           "/bin/bash -c 'ping    14 seconds ago      Up 14 seconds                           furious_curie 

now try to attach to it and you will see that, its not retuning the shell. Since docker attach always attaches to the PID1 whcih is the process passes in the docker run command. here its not the shell but its the ping and hence you are connected but it wont be a shell and the ping output is seen.

root@ubuntu14-04:/home/kmaringanti# docker attach 41a0577aba34
64 bytes from ( icmp_seq=31 ttl=53 time=24.5 ms
64 bytes from ( icmp_seq=32 ttl=53 time=23.3 ms
64 bytes from ( icmp_seq=33 ttl=53 time=25.9 ms
64 bytes from ( icmp_seq=34 ttl=53 time=22.8 ms
64 bytes from ( icmp_seq=35 ttl=53 time=23.3 ms

docker exec -it 41a0577aba34 /bin/bash

in this way you are into the container with shell prompt and not the PID1 process. now check the process list and see the PID1 and its ping

root@41a0577aba34:/# ps -ef
root         1     0  0 14:31 ?        00:00:00 ping
root         8     0  0 14:35 ?        00:00:00 /bin/bash
root        20     8  0 14:35 ?        00:00:00 ps -ef