-d runs the container in detached mode (does not block the terminal)
-p map a port from inside the container to one that’s exposed to the outside
# Start a container from an imagedocker run --name <container-name> --rm -d <image-name># Start a container and expose a port to the outsidedocker run --name <container-name> --rm -d -p <port>:<port> <image-name># Stop a running containerdocker stop <container-name># Remove a stopped containerdocker rm <container-id/name># Get rid of old containersdocker system prune
Attach and Detach Containers, Interactive Sessions
-it run a container in interactive mode (open a terminal session)
# Start a container from an imagedocker run -it <image-name># Attach an active container to the terminaldocker attach <container-name/id># For a stopped container, use attach + interactivedocker start -a -i <container-id/name>
Basic Image Commands
-t gives the image a name
# Build a new imagedocker build .# Build and tag an imagedocker build -t <image-name>:<tag> .# Remove an image docker rmi <image-name># Inspect an imagedocker image inspect <image-id>