Note: When typing any Docker container ID, you don't have to type the whole thing, just the necessary number of characters that will differentiate the container from others.
Start a Container
dockerrunansibledockerrunmongodb...# This runs container in the foreground (attached to stdout of container and you will see output)dockerrun-d<repo-name># this runs container in the background (detached, won't see output)dockerrun<image-name>:<version># ex. docker run redis:4.0 (called a tag)dockerrun--namewebappansible# Name conainer webapp
List Running Containers
dockerpsdockerps-a# Previously exited containers too
# When you need STDIN or to interact with the containerdockerrun-i<repo># will not show user input prompt thoughdockerrun-it<repo># for STDIN and showing prompt (we attach ourselves to the docker container's terminal)
Inspect Containers
# Shows environmental variables of container and other information dockerinspect<container_name>
Container Logs
dockerlogs<container_name>
Set Environment Variables
dockerrun-eENV_VAR=blue<image_name># Adding password to SQL databasedockerrun-eMYSQL_ROOT_PASSWORD=<password>mysql
Build Image
dockerbuild-t<image_name>/directory/to/Dockerfile# Creates image based off of your Dockerfile locally# e.g. docker build -t webapp .dockerbuild<dockerfile_name>-t<image_name>