docker run nginx # run nginx, auto download if not founddocker psdocker ps -a # alldocker stop ContainerIddocker rm ContainerIddocker images # list available imagesdocker rmi nginx # remove imagesdocker pull nginx # download image but not rundocker exec container_name command docker exec ubuntu cat /etc/hosts
Images
docker pull <img># docker pull ubuntudocker images # list images
run/start
docker run kodekloud/simple-webapp # run a webserver in attach modedocker run -d kodekloud/simple-webapp # detach modedocker attach ContainerId # re-attach the container
docker run -it centos bash # run bash in centos, then execute bash and auto logindocker run -it --name testbox ubuntu bashdocker start -ai testbox # start existing container
ps
docker ps # show running containersdocker ps -a # show all containers
Check version
docker --versiondocker compose version
Detach
# default<ctrl+p> <ctrl+q># set detach keys when starting a containerdocker run --detach-keys="ctrl-],ctrl-]" -it myimage