« Back to overview

List running docker containers
docker ps
Log in into a docker container shell
docker exec -i -t {CONTAINER_ID} /bin/sh
Get a container id from part of its name or part of it's name
# 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
Show all containers and open a shell by entering a name
docker ps && echo "Part of the container name to login to:" && read _name && docker exec -it $(docker ps -aqf "name=$_name") /bin/sh