Version:
Domino 5.x
Issue:
Environment builds on 'apt-key add' fail with the following error:
#7 [3/8] RUN apt-key add -
#7 0.127 Warning: apt-key output should not be parsed (stdout is not a terminal)
E: This command can only be used by root.
#7 ERROR: process "/bin/bash -c apt-key add -" did not complete successfully: exit code: 1
------
> [3/8] RUN apt-key add -:
#7 0.127 Warning: apt-key output should not be parsed (stdout is not a terminal)
#7 0.129 E: This command can only be used by root.
------
Build failed: failed to solve: process "/bin/bash -c apt-key add -" did not complete successfully: exit code: 1
Failed to build image: buildkit solve issue: failed to solve: process "/bin/bash -c apt-key add -" did not complete successfully: exit code: 1
Root Cause:
Note the error in the build log:
E: This command can only be used by root.
Environment builds in Domino default to running as the Ubuntu user. The apt-key command is part of many examples in the Domino documentation, for example:
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install msodbcsql17
ref: https://docs.dominodatalab.com/en/latest/user_guide/634c13/connect-to-mssql/#_r_and_rodbc_to_mssql
You may also be independently using the apt-key command as part of your own environment build, of course.
Resolution:
The resolution is to simply change the user to root prior to the apt-key command. Following our example:
USER root
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install msodbcsql17
USER ubuntu
Note that while not mandatory, returning the user to the ubuntu user at the end of the code block is a best practice.
Notes/Information:
Domino documentation also notes this as a best practice when installing packages:
https://docs.dominodatalab.com/en/latest/user_guide/813d89/use-dockerfile-instructions/
Comments
0 comments
Please sign in to leave a comment.