Docker Flashcards

1
Q

How to see list of running containers in Docker?

A

docker container ls

docker container ls -a —– (show all containers)

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

how to remove container in Docker?

A

docker container rm [container id]

container id can be only first 3 digits

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

Create an run a container in foreground [Docker]

A

$ docker container run -it -p 80:80 nginx

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

Create an run a container in background

A

$ docker container run -d -p 80:80 nginx

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

difference between running container in foreground and background docker

A

You can start a docker container in detached mode with a -d option. So the container starts up and run in background. That means, you start up the container and could use the console after startup for other commands.

The opposite of detached mode is foreground mode. That is the default mode, when -d option is not used. In this mode, the console you are using to execute docker run will be attached to standard input, output and error. That means your console is attached to the container’s process.

In detached mode, you can follow the standard output of your docker container with docker logs -f .

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

List running containers [Docker]

A

$ docker container ls

$ docker ps

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

List all containers (Even if not running) [Docker]

A

$ docker container ls -a

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

Stop container
Stop all running containers
[Docker]

A

$ docker container stop [ID]

$ docker stop $(docker ps -aq)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Remove container (Can not remove running containers, must stop first)
To remove a running container use force(-f)
A

$ docker container rm [ID]

$ docker container rm [ID] [ID] [ID]

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

Get logs (Use name or ID) [Docker]

A

$ docker container logs [NAME]

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

List processes running in container [Docker]

A

$ docker container top [NAME]

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

Docker containers are often compared to virtual machines but they are actually just processes running on your host os. In Windows/Mac, Docker runs in a mini-VM so to see the processes youll need to connect directly to that. On Linux however you can run “ps aux” and see the processes directly

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

Remove all images [Docker]

A

$ docker rmi $(docker images -a -q)

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

About images [Docker]

A
  • Images are app bianaries and dependencies with meta data about the image data and how to run the image
  • Images are no a complete OS. No kernel, kernel modules (drivers)
  • Host provides the kernel, big difference between VM
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

View info on container [Docker]

A

$ docker container inspect [NAME]

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

Specific property (–format) for container [Docker]

A

$ docker container inspect –format ‘{{ .NetworkSettings.IPAddress }}’ [NAME]

17
Q

Use exec to edit config, etc [Docker]

A

$ docker container exec -it mysql bash

18
Q

Get port for network [Docker]

A

$ docker container port [NAME]

19
Q

Connect existing container to network [Docker]

A

$ docker network connect [NETWORK_NAME] [CONTAINER_NAME]

20
Q

what is Volume? [Docker]

A

Makes special location outside of container UFS. Used for databases

21
Q

Bind Mount what is it? [Docker]

A

Link container path to host path

22
Q

Cleanup unused volumes

[Docker]

A

$ docker volume prune

23
Q

docker-compose CLI - used for ?

A

local dev/test automation with YAML files