Run a docker image
docker run nginx
Run a specific tag of a docker image
docker run redis:4.0
List all running containers
docker ps
List ALL containers
docker ps -a
Stop container
docker stop <containerID>
Remove container
docker rm <containerID>
List all images
docker images
Remove image
docker rmi <image>
Download image
docker pull <image>
Append a command
docker run ubuntu sleep 5
Execute a command inside container
docker exec <containerID> cat /etc/hosts
Run detached (background)
docker run -d <image>
Re-attach to terminal
docker attach <containerID>
Interactive mode
docker run -i <image>
Interactive with terminal
docker run -it <image>
Mapping Port
docker run -p 80:5000 <image>
Mapping folder
docker run -v /opt/datadir:/var/lib/mysql <image>
Inspect container
docker inspect <containerID>
Logs
docker logs <containerID>
Environment variables
docker run -e APP_COLOR=green simple-webapp-color