Docker CLI
Create a container
docker create [image]
Start a container
docker start [name|image]
Create and start a container
$ docker run [image]
docker run \
-i \ # Keep STDIN open even if not attached (To use keyboard)
-t \ # Allocate a pseudo-TTY (To use Terminal)
--rm \ # Automatically remove the container when it exits
-d \ # Run container in background and print container ID
--name string \ # Assign a name to the container
-p 13306:3306 # Publish a container's port(s) to the hos
-v /opt/example:/example \ # Bind mount a volume
IMAGE \ # Image
[COMMAND] # Command in the container
-it == -i -t
Check the running container
docker ps
Check the status of all running container
docker ps -a
Check the detail of the container
$ docker inspect [container]
Pause the container
$ docker pause [container]
Resume the container
$ docker unpause [container]
Stop the container (Pass SIGTERM)
$ docker stop [container]
Stop all container
$ docker stop $(docker ps -a -q)
Kill the container (Pass SIGKILL)
$ docker kill [container]
Remove the container
$ docker rm [container]
Remove the container after running
$ docker run --rm ...
Remove the container after kill (Pass SIGKILL)
$ docker rm -f [container]
Remove all stopped container
$ docker container prune
Running and Connecting Maria DB docker
I’ve used Docker Desktop on macOS silicon.
docker pull mariadb