Docker - Basics Flashcards
CLI run a conatiner
docker run -dp tag-of-the-image
-d flag in run command
run the container in detached mode (in the background)
-p flag in run command
maps the hosts port to the containers port (3000:3000)
CLI to build a container image
docker build -t name(tag)-for-the-image
-t flag in build command
adds a tag or text name/label to reference the image
CLI list container ids
docker ps
Needed to run a build
Dockerfile in the root dir of the project, no extension
CLI to stop an image
docker stop image-id
CLI remove an image
docker rm
CLI stop and remove an image
docker rm -f
CLI create a named volume
docker volume create name-of-volume
CLI map volume to container with build
docker build -td port:port -v named-of-volume:/dir/location tag-of-container
CLI view the mountpoint of the volume
docker volume inspect name-of-volume
CLI view volume logs
docker logs -f volume-id
CLI start a dev-mode container
docker run -dp hostPort:conatinerPort -w working-directory -v bindmount-host-dir:container-dir image-to-use sh -c ‘command-to-run’
CLI start app with compose file
docker-compose up -d
CLI stop compose app
docker-compose down
CLI view compose logs
docker-compose logs -f
CLI stop application and remove volumes, images, and orphans with compose file
docker-compose down –rim all -v –remove-orphans
CLI execute a command in a container
docker exec -it name_of_container command
bash as command to get shell
-it flag is for interactive and pseudo TTY