ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 137 - DCA discussion

Report
Export

Will this command mount the host's '/data* directory to the ubuntu container in read-only mode?

Solution. 'docker run -add-volume /data /mydata -read-only ubuntu'

A.

Yes

Answers
A.

Yes

B.

No

Answers
B.

No

Suggested answer: B

Explanation:

= The commanddocker run -add-volume /data /mydata -read-only ubuntuwill not mount the host's/datadirectory to the ubuntu container in read-only mode. The reason is that the command has several syntax errors and invalid options.The correct command to mount a host directory to a container in read-only mode isdocker run --mount type=bind,source=/data,target=/mydata,readonly ubuntu12. The commanddocker run -add-volume /data /mydata -read-only ubuntuhas the following problems:

The option-add-volumeis not a valid option fordocker run.The valid options for mounting a volume or a bind mount are--mountor-v12.

The option-read-onlyis not a valid option fordocker run.The valid option for making the container's root filesystem read-only is--read-only3.However, this option will not affect the mounted volumes or bind mounts, which have their ownreadonlyoption12.

The argument/data /mydatais not a valid argument fordocker run.The argument fordocker runshould be the command to run inside the container, such asbashorping4.The source and target of the volume or bind mount should be specified in the--mountor-voption, separated by a colon12.

Therefore, the commanddocker run -add-volume /data /mydata -read-only ubuntuwill not work as intended, and will likely produce an error message or an unexpected result.Reference:

Use bind mounts

Use volumes

docker run

Docker run reference

asked 08/11/2024
Fai Malali
30 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first