Answers: <p>The problem seems to be that the ubuntu:latest image is stale.
  Changing to ubuntu:bionic fixes the issue:</p>
  <pre><code>FROM ubuntu:bionic AS toolchain
  ENV DEBIAN_FRONTEND=noninteractive
  RUN apt-get update &amp;&amp; apt-get install -y \
    build-essential \
    g++-5
  </code></pre>
  <p>I don't know why an old image is being used, but that seems like a separate question.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-01-29T18:10:56.683Z
Answers: though this doesn't explain why it builds on one machine and not another.  shouldn't both machines be running off the same base image and therefore encounter the same error in both?
Answers: Homan
Answers: CC BY-SA 4.0
Answers: 2022-02-06T15:12:14.437Z
Answers: That's how it should work, but the ubuntu:latest image was not the same on the two machines. One of them had an older cached image an did not update to the later version.
Answers: Craig
Answers: CC BY-SA 4.0
Answers: 2020-10-17T20:42:00.153Z
Answers: 2020-10-17T20:42:00.153Z
Answers: Craig
Body: <p>On my own machine (Windows 10, Docker Desktop 2.1.0.3) the build succeeds and runs.
  On another machine (Ubuntu 18.04, docker CE 19.03.13) the build fails with the error shown.</p>
  <p>Why does the build work on one machine but fail another?</p>
  <p>dockerfile:</p>
  <pre><code>FROM ubuntu:latest AS toolchain
  ENV DEBIAN_FRONTEND=noninteractive
  RUN apt-get update &amp;&amp; apt-get install -y \
    build-essential \
    g++-5
  </code></pre>
  <p>error:</p>
  <pre><code>Package g++-5 is not available, but is referred to by another package.
  This may mean that the package is missing, has been obsoleted, or
  is only available from another source
  However the following packages replace it:
    gcc-10-test-results gcc-9-test-results gcc-8-test-results gcc-7-test-results
  
  Package 'g++-5' has no installation candidate
  The command '/bin/sh -c apt-get update &amp;&amp; apt-get install -y   build-essential   g++-5' returned a non-zero code: 100
  </code></pre>
  
Tags: <docker><ubuntu>
Title: docker build fails on one machine but succeeds on another
UserDisplayName: Craig
ThreadText: # docker build fails on one machine but succeeds on another
  
  (Asked by: username_0 on 2020-10-16)
  
  On my own machine (Windows 10, Docker Desktop 2.1.0.3) the build succeeds and runs.
  On another machine (Ubuntu 18.04, docker CE 19.03.13) the build fails with the error shown.
  
  Why does the build work on one machine but fail another?
  
  dockerfile:
  
  ```
  FROM ubuntu:latest AS toolchain
  ENV DEBIAN_FRONTEND=noninteractive
  RUN apt-get update && apt-get install -y \
    build-essential \
    g++-5
  
  ```
  
  error:
  
  ```
  Package g++-5 is not available, but is referred to by another package.
  This may mean that the package is missing, has been obsoleted, or
  is only available from another source
  However the following packages replace it:
    gcc-10-test-results gcc-9-test-results gcc-8-test-results gcc-7-test-results
  
  Package 'g++-5' has no installation candidate
  The command '/bin/sh -c apt-get update && apt-get install -y   build-essential   g++-5' returned a non-zero code: 100
  
  ```
  
  **Tags:** docker, ubuntu
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-10-17. Score: 0 | Accepted answer
  
  The problem seems to be that the ubuntu:latest image is stale.
  Changing to ubuntu:bionic fixes the issue:
  
  ```
  FROM ubuntu:bionic AS toolchain
  ENV DEBIAN_FRONTEND=noninteractive
  RUN apt-get update && apt-get install -y \
    build-essential \
    g++-5
  
  ```
  
  I don't know why an old image is being used, but that seems like a separate question.
  
  > **Comments:**
  > **username_1**: though this doesn't explain why it builds on one machine and not another.  shouldn't both machines be running off the same base image and therefore encounter the same error in both?  
  > **username_0**: That's how it should work, but the ubuntu:latest image was not the same on the two machines. One of them had an older cached image an did not update to the later version.  
  
  ---
  
  