ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 330 - XK0-005 discussion

Report
Export

An operations engineer is planning to start a container running a PostgreSQL database. The engineer wants the container to start automatically at system startup, mount the /home/db directory as /var/lib/postgresql inside the container, and expose port 5432 to the OS. Which of the following commands should the engineer run to achieve this task?

A.

docker run -d --restart always -p 5432:5432 -v /home/db:/var/lib/postgresql postgresql:12

Answers
A.

docker run -d --restart always -p 5432:5432 -v /home/db:/var/lib/postgresql postgresql:12

B.

docker run -d --restart -p 5432:5432 --volume /var/lib/postgresql:/home/db postgresql:12

Answers
B.

docker run -d --restart -p 5432:5432 --volume /var/lib/postgresql:/home/db postgresql:12

C.

docker run -d --attach --platform 5432:5432 --volume /home/db:/var/lib/postgresql postgresql:12

Answers
C.

docker run -d --attach --platform 5432:5432 --volume /home/db:/var/lib/postgresql postgresql:12

D.

docker run -d --init --restart --publish 5432:5432 --workdir /home/db:/var/lib/postgresql postgresql:12

Answers
D.

docker run -d --init --restart --publish 5432:5432 --workdir /home/db:/var/lib/postgresql postgresql:12

Suggested answer: A

Explanation:

The command docker run -d --restart always -p 5432:5432 -v /home/db:/var/lib/postgresql postgresql:12 ensures that the PostgreSQL container is started in detached mode (-d), it restarts automatically on system startup (--restart always), mounts the host directory /home/db to /var/lib/postgresql, and exposes port 5432. This is a typical setup for running a database in a Docker container.

asked 09/10/2024
GISELE AGNARAMON
45 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first