1. Overview Flashcards

1
Q

What is a Dockerfile?

A

A text document that contains all the commands a user could call on the command line to assemble a docker image.

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

What is the use of a .dockerignore file?

A

It allows you to exclude files from the context like a .gitignore file allow you to exclude files from your git repository. It helps to make build faster and lighter by excluding from the context big files or repository that are not used in the build.

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

How do you specify what docker image to use as a template in a Dockerfile?

A

By using the FROM command.

eg. FROM node

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

How do you specify the work directory to be created in a Dockerfile?

A

By using the WORKDIR command.

eg. WORKDIR /usr/src/app

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

How do you copy a file or multiple files from the root of the project into the workdir in a Dockerfile?

A

By using the COPY command.

eg. COPY package*.json ./

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

How do you run an npm command in a Dockerfile?

A

By using the RUN command.

eg. RUN npm install

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

How do you copy the entire root content of a project into the work directory in a Dockerfile?

A

By using the COPY command.

eg. COPY . .

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

How do you specify a port to be exposed in a Dockerfile?

A

By using the EXPOSE command.

eg. EXPOSE 4000

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

How do you specify a default command to be executed in order to run the app in the container in a Dockerfile?

A

By using the CMD commad.

eg. CMD ["npm", "start"]

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

Can you have more than one CMD commands in a Dockerfile?

A

No. Only the last CMD will take effect.

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

How do you create a new Docker image using a Dockerfile?

A

By executing the docker build command after having specified the image name via the -t flag, and the directory that the Dockerfile is in.

eg. docker build -t atlaskaplan/simple-backed .

PS. the dot (.) at the end means that the Dockerfile is in the current directory.

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

How do you list all the Docker images you created alongside their IDs, creation dates, tags, and sizes in the commandline?

A

By executing the docker images command.

eg. docker images

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

How do you delete a Docker image from your system?

A

By executing the docker rmi command and specifying the image ID.

eg. docker rmi e30b45e15491

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

How do you run a Docker image?

A

By executing the docker run command having specified the port using the -p flag and specifying the Docker image’s name.

eg. docker run -p 4000:4000 atlaskaplan/simple-backend

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

How do you stop a running Docker container?

A

By executing the docker stop command with the Docker container’s ID or name.

eg.

docker stop d56bf8342cfa
OR
docker stop container-name

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

How do you list all Docker containers that are currently running as well as additional information about them in the commandline?

A

By executing the docker ps command.

eg. docker ps

17
Q

How do you start a docker container?

A

By executing the docker start command with the Docker container’s ID or name.

eg.

docker start d56bf8342cfa
OR
docker start container-name

18
Q

How do you push a Docker image onto your DockerHub?

A

By executing the docker push command with the Docker image’s ID or name.

eg.

docker push d56bf8342cfa
OR
docker push container-name

19
Q

How do you pull an image from DockerHub?

A

By executing the docker pull command with the Docker image’s name.

eg. docker pull node