exam questions

Exam 350-901 All Questions

View all questions & answers for the 350-901 exam

Exam 350-901 topic 1 question 151 discussion

Actual exam question from Cisco's 350-901
Question #: 151
Topic #: 1
[All 350-901 Questions]

The access token for a Webex bot has been stored in an environment variable using the command: export bot_token=6bec40cf957de397561557a4fac9ea0
The developer now wants to containerize the Python application which will interact with the bot, and will use this build command to add the token to the build image: docker build --build-arg BOT_TOKEN=$bot_token
Which Dockerfile should be used to build the Docker image so that the bot access token is available as an environment variable?
A.

B.

C.

D.

Show Suggested Answer Hide Answer
Suggested Answer: D

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ferock
Highly Voted 2 years, 6 months ago
B Here’s How: While you can’t directly set ENV variable values when running docker build, you can use ARG to pass through --build-arg values right into your ENV instructions. Source: https://vsupalov.com/docker-build-time-env-values/#:~:text=While%20you%20can't%20directly,right%20into%20your%20ENV%20instructions.&text=You%20can%20change%20the%20value,build%20without%20editing%20the%20Dockerfile.
upvoted 7 times
...
al_mon
Most Recent 3 months, 1 week ago
ARG TOKEN=$BOT_TOKEN ENV WEBEX_TEAMS_ACCESS_TOKEN="$TOKEN" CMD ["python", "bot_app.py"] Explanation: ARG TOKEN=$BOT_TOKEN: This allows the build-time argument BOT_TOKEN to be passed using the docker build --build-arg BOT_TOKEN=$bot_token command. The value of BOT_TOKEN (e.g., the Webex bot token) will be available during the build process. ENV WEBEX_TEAMS_ACCESS_TOKEN="$TOKEN": This sets an environment variable WEBEX_TEAMS_ACCESS_TOKEN in the Docker container, making the token available to the application runtime. CMD ["python", "bot_app.py"]: This specifies the command to run the Python application when the container starts.
upvoted 1 times
...
xorajav691
9 months, 1 week ago
None of the answers is correct. The Build Arg is called BOT_TOKEN, and its not consumed in any of the answers. It would need to be: ARG BOT_TOKEN ENV WEBEX...="$BOT_TOKEN"
upvoted 2 times
...
Zizu007
1 year, 1 month ago
B is correct: you can have environment variables (ENV) and build arguments (ARG) with different names in a Dockerfile. In fact, it's common practice to use different names to make their purposes clear and to avoid any potential conflicts or confusion
upvoted 2 times
...
after_eight
1 year, 3 months ago
This should be B. D seems valid enough, but when trying to build the container using the given Dockerfile, i got the following error : [Warning] One or more build-args [BOT_TOKEN] were not consumed thus you have to use ARG command to retrieve ARGs However B is incorrect too, since the ARG syntax is : ARG <my arg>=default My guess is that the correct Dockerfile is ARG BOT_TOKEN ENV WEBEX..="$BOT_TOKEN"
upvoted 1 times
...
ballastleaf8
1 year, 4 months ago
I think A and C can be disregarded to the use of the EXPORT statement. Otherwise, both B and D would match the question. Analysing the difference between B and D, ChatGPT has the following view which makes me thing B would be better: To summarize, the key difference is that the first Dockerfile (b) allows for flexibility in passing the value of TOKEN as an argument during the build process, while the second Dockerfile (d) sets the environment variable directly without the ability to override it during the build process.
upvoted 2 times
...
guych77
1 year, 5 months ago
D. As the build statement references BOT_TOKEN and not TOKEN so the provided answer is correct in my opinion
upvoted 3 times
...
__al__
2 years, 7 months ago
B looks like the correct approach
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago