Docker Flashcards

1
Q

What is a container?

A

A container is an isolated unit of software that is based on an image. It is a running instance of that image.

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

What is Docker?

A

Docker is a container technology for creating and managing containers.

Docker allows us to have the same exact environment for development and production.

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

What is an Image?

A

A file used to execute code in a Docker container. Holds all the logic and code a container needs.

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

Steps to create own our docker image

A
  1. Base on default image (FROM)
  2. Set work directory folder
  3. Copy code
  4. Run commands (npm install)
  5. Expose port for Docker
  6. Run commands when container is started
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Command to create the image

A

docker build [path]

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

Command to run an image as a container

A

docker run [image name/id]

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

Command to stop a container

A

docker stop [image name/id]

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

Are images read only?

A

Yes, once an image is built, it is locked in

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

What image layers are changed after finding a change in an image when rebuilding?

A

All layers after the changing layer are rebuilt

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

Why do we have images and containers? Why not just containers?

A

This allows multiple containers to be based on the same image without interfering with each other

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

What are layers in the context of images?

A

Every instruction in an image creates a cacheable layer. Layers help with image rebuilding and sharing

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

Difference between detached and attached mode

A

In detached mode, the container runs in the background of your terminal. It does not receive input or display output.

In attached mode, it can attach the console to the process’s output

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

Command to remove containers/image

A

Containers: docker rm [container name]
Images: docker rmi [image id]

Remove all stopped containers: docker container prune

Remove all unused images: docker image prune

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

What is a DockerFile?

A

It is a text file that has all commands which need to be run for building a given image

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

What is Docker Compose?

A

Docker-compose is used for creating multiple containers, hosting them and establish communication between them

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

Docker command that lists the status of all docker containers?

A

docker ps -a

17
Q

What is Docker Hub?

A

It is a public cloud-based registry provided by Docker for storing public images of the containers along with the provision of finding and sharing them.

18
Q

Can a paused container be removed from Docker?

A

No, it is not possible! A container MUST be in the stopped state before we can remove it

19
Q

What is Docker Swarm?

A

Docker Swarm is native clustering for Docker. It turns a pool of Docker hosts into a single, virtual Docker host

20
Q

What is the lifecycle of a Docker Container?

A
  1. Create container
  2. Run container
  3. Pause/Unpause
  4. Stop container
  5. Kill container
  6. Destroy container