Errors when using apt-get in environments

Overview

When building an environment the following errors may be seen when running an apt-get install command

Oct 26 2017 11:31:48 +0100  Step 17 : RUN sudo apt-get install apt-transport-https
<truncated>
Oct 26 2017 11:32:31 +0100  After this operation, 234 kB of additional disk space will be used.
<truncated>
Oct 26 2017 11:32:31 +0100  Err http://archive.ubuntu.com/ubuntu/ trusty-updates/main apt-transport-https amd64 1.0.1ubuntu2.17
Oct 26 2017 11:32:31 +0100    Could not resolve 'archive.ubuntu.com'
Oct 26 2017 11:32:31 +0100  Err http://archive.ubuntu.com/ubuntu/ trusty-security/main apt-transport-https amd64 1.0.1ubuntu2.17
Oct 26 2017 11:32:31 +0100    Could not resolve 'archive.ubuntu.com'
<truncated>
Oct 26 2017 11:32:31 +0100  E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Oct 26 2017 11:32:31 +0100  The command '/bin/sh -c sudo apt-get install apt-transport-https' returned a non-zero code: 100
Oct 26 2017 11:32:31 +0100  ERROR: ProgressMessage{id=null, status=null, stream=null, error=The command '/bin/sh -c sudo apt-get install apt-transport-https' returned a non-zero code: 100, progress=null, progressDetail=null}

 

Cause

When running the apt-get command, the -y switch must also be used to confirm any prompts, otherwise the install may fail. As we can see in this case the error hints towards connectivity when in fact it was missing the confirmation switch to run in non-interactive mode.

Solution

Add a confirmation switch into your command, for example:

USER root
RUN apt-get install -y <package>
Was this article helpful?
0 out of 0 found this helpful