What containers are running at the moment?
docker ps
What containers were run or are running?
docker ps -a
Run an image
docker run hello-world:latest # By Image ID docker run 4ab4c602aa5e # Run a container with an interactive program inside docker run docker/whalesay cowsay hello
Run an image and name it
docker run -d --name=MyWeb1 nginx
Run a container with a bash terminal
# -i interactively, -t connected to the current terminal, command you want the image to start up with: a /bin/bash shell docker run -it centos:latest /bin/bash
Detached mode: run the container in the background and print the new container ID.
docker run -d centos:latest /bin/bash
Execute something in a running container
docker exec -it web1 /bin/bash # exit the container exit
Start a container
docker start web1
Restart a container
docker restart web1
Stopping Running Containers
Stop a running container
# By CONTAINER ID docker stop a3c73d18d45c # By NAMES docker stop stupefied_lovelace