CLI Flashcards
What is the command signature for running contianers?
docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...]
What is the command to run a container in the background?
docker run -d=true imageName
or
docker run -d imageName
What is the command to run a container with an interactive terminal?
docker run -it imageName
What is the command to run a mongo container and use mongosh inside it?
docker run -d --name mongo-container mongo docker exec -it mongo-container bash mongosh
What is the command to run a container with specific environment variables?
docker run -e "key=value" -e "foo=bar" imageName
What is the command signature for building images?
docker build [OPTIONS] PATH
What is the command to build an image from a git repository?
docker build gitUrl
What command can be used to build an image with a tag that allows it to be pushed to a registry?
docker build -t username/repoName:tag .
What command can be used to build a multi-architecture image and push the image to a registry?
docker buildx build --platform=linux/amd64,linux/arm64 --tag username/repository:version --push .
What is the command signature for pulling images from a registry?
docker pull [OPTIONS] NAME:TAG
What is the command signature for removing a container?
docker rm [OPTIONS] CONTAINER...
What is the conmand signature for removing images?
docker rmi [OPTIONS] IMAGE...