Docker - Basics Flashcards

1
Q

CLI run a conatiner

A

docker run -dp tag-of-the-image

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

-d flag in run command

A

run the container in detached mode (in the background)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

-p flag in run command

A

maps the hosts port to the containers port (3000:3000)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

CLI to build a container image

A

docker build -t name(tag)-for-the-image

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

-t flag in build command

A

adds a tag or text name/label to reference the image

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

CLI list container ids

A

docker ps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Needed to run a build

A

Dockerfile in the root dir of the project, no extension

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

CLI to stop an image

A

docker stop image-id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

CLI remove an image

A

docker rm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

CLI stop and remove an image

A

docker rm -f

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

CLI create a named volume

A

docker volume create name-of-volume

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

CLI map volume to container with build

A

docker build -td port:port -v named-of-volume:/dir/location tag-of-container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

CLI view the mountpoint of the volume

A

docker volume inspect name-of-volume

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

CLI view volume logs

A

docker logs -f volume-id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

CLI start a dev-mode container

A

docker run -dp hostPort:conatinerPort -w working-directory -v bindmount-host-dir:container-dir image-to-use sh -c ‘command-to-run’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

CLI start app with compose file

A

docker-compose up -d

17
Q

CLI stop compose app

A

docker-compose down

18
Q

CLI view compose logs

A

docker-compose logs -f

19
Q

CLI stop application and remove volumes, images, and orphans with compose file

A

docker-compose down –rim all -v –remove-orphans

20
Q

CLI execute a command in a container

A

docker exec -it name_of_container command

bash as command to get shell

-it flag is for interactive and pseudo TTY