Development Flashcards

1
Q

What’s the purpose of WORKDIR instruction?

A

It creates a new directory inside the container and runs all subsequent instructions inside the same directory

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

Different instructions executed inside the WORKDIR directory?

A
RUN
ADD
COPY
ENTRYPOINT
CMD
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s the purpose of CMD command?

A

It runs an executable right after container starts

CMD [“java”,”-jar”,”myApp.war”]

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

What’s the format of CMD command?

A

CMD [“executable”,”parameter1”,”parameter2”]

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

How to run container in background to free the terminal?

A

Using “-d” flag

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

What is “bind mount” and it’s advantage?

A

Bind mount is the mechanism to “bind” host directory with container directory.
By this way we can change files in host directory and it will be reflected in the container immediately.

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

How to bind any directory of the host machine to container machine?

A

It can be done during start of the process:
docker:
docker run -v :/ -it debian /bin/bash

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

How to view the logs of the container, if running in background?

A

docker logs

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

What’s the instruction to create a group inside the container?

A

RUN groupadd -r

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

How to add a user in a group inside Docker file and switch to the same user?

A

RUN useradd -r -g

USER

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

What’s the ideal position for setting up User in Docker file?

A

Before running any executable

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

How to expose container port to HOST?

A

EXPOSE 8080

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

How to map container port to any available port of the Host machine?

A

docker run -p 8080:8081

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

How to find container port mapping?

A

docker port

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

How to pass environment variables to the run command?

A

docker run -e “ENV=DEV”

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

How to run shell script instead of CMD instructions?

A

COPY cmd.sh /app

CMD [“/cmd.sh”]