Docker Flashcards
list all running containers
docker ps
list all containers (running and not running)
docker ps -a
stop one or more running containers
docker stop a123b
or use container name: docker stop silly_sherlock
run a new container from an image
docker run nginx
downloads the nginx image if it doesn’t exist
run a container in detached mode
docker run -d mycontainer
list all images stored locally
docker images
remove one or more images
docker rmi image_id
download an image from the repository without running
docker pull image_name
run a command in a running container
docker exec my_container command
docker exec my_container touch /tmp/newfile.txt
run a particular version of an image
docker run redis:6.2
use :version
tag
Docker defaults to the latest
tag (the most recent version)
run container in interactive mode
docker run -it ubuntu
-it
allocates a pseudo-TTY
map a port on the container to a port on the host
docker run -p host:container image
docker run -p 80:3000 nginx
share data between the host and container (so data will persist if container is destroyed)
docker run -v hostdir:containerdir image
docker run -v /mydata:/var/lib/mysql mysql
display detailed info on a container, including config details, network settings, etc
docker inspect a123b4
docker inspect silly-sherlock
<– or use the container name
fetch the logs of a container
docker logs a123b4