XK0-005 practice question 7 of 10
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?
Full set: 487 questionsThe docker run command initializes and starts a container from a specified image using provided configurations. The -d flag runs the container in detached mode in the background. The --restart always flag ensures the container restarts automatically upon system reboot or container exit. Port forwarding from the host OS to the container is specified via -p 5432:5432, binding host port 5432 to container port 5432. Volume mounting uses the syntax -v :, which correctly maps the host directory /home/db to /var/lib/postgresql inside the container. Combining these parameters allows the PostgreSQL service to run persistently, retain persistent database storage on the host, and accept network connections on host port 5432.
B. Option B reverses the host and container volume paths and lacks a valid restart policy argument required by the --restart flag.
C. Option C incorrectly uses --platform for port binding and combines --attach with -d, which conflict with detached operation.
D. Option D misuses --workdir instead of volume flags to bind directories and omits the mandatory restart policy for --restart.
Docker Documentation, "docker run reference", Section: "Restart policies (--restart)", "Bind mounts (-v, --mount)". https://docs.docker.com/engine/reference/commandline/run/
Red Hat Enterprise Linux 8, "Building, running, and managing containers", Section 3.2: Managing Container Lifecycle.
Keep practicing
Take the free XK0-005 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other XK0-005 practice questions
- Question 1A Linux engineer needs to block an incoming connection from the IP address 2.2.2.2 to a s…
- Question 2A systems administrator identifies multiple processes in a zombie state. Which of the fol…
- Question 3An administrator made a change to a system's network configuration. Which of the followin…
- Question 4Which of the following can reduce the attack surface area in relation to Linux hardening?
- Question 5A Linux administrator needs to check extended permissions applied to the directory test. …
- Question 6A Linux systems administrator is updating code. After completing the update, the administ…
