docker ps
docker exec -i -t {CONTAINER_ID} /bin/sh
# get the container containing the name php
docker ps -aqf "name=api_php"
# use it dynamically
echo $(docker ps -aqf "name=api_php")
# open a shell in the container
docker exec -i -t $(docker ps -aqf "name=api_php") /bin/sh
# execute a command on that container
docker exec -it $(docker ps -aqf "name=api_php") touch test
docker ps && echo "Part of the container name to login to:" && read _name && docker exec -it $(docker ps -aqf "name=$_name") /bin/sh