Dockerfile works when every line run interactively, but fails using docker build

I have a simple Dockerfile that downloads the node.js source tarball, checksums it, extracts it, builds and installs it. The checksum works when manually run in an interactive docker container, but fails when running the exact same commands when building a Dockerfile.


  • Building a docker image from inside a docker container
  • docker build inside official jenkins container
  • building in docker using buildpack-deps, but dependencies don't seem to be installed?
  • Canonical way to checksum downloads in a Dockerfile?
  • Setting name for a docker image
  • automated docker build run error: Unable to find image
  • docker run -i -t ubuntu:12.04 /bin/bash

    cd /tmp

    apt-get update -y

    apt-get install wget build-essential automake -y



    sha256sum -c SHASUM256.txt 2>&1|grep -qs OK

    tar -xvf node-v0.10.26.tar.gz && cd node-v0.10.26

    ./configure && make && make install

    Doesn’t work:

    sudo docker build -t=”my_docker_node_image_01″ .

    Error is:

    sudo docker build -t="my_docker_node_image_01" .                                        
    Uploading context 7.168 kB
    Uploading context 
    Step 0 : FROM ubuntu:12.04
     ---> 9cd978db300e
    Step 1 : RUN cd /tmp
     ---> Using cache
     ---> 0467ad75bbd6
    Step 2 : RUN apt-get update -y
     ---> Using cache
     ---> d2933f250090
    Step 3 : RUN apt-get install wget build-essential automake -y
     ---> Using cache
     ---> e8a71b28782a
    Step 4 : RUN wget
     ---> Using cache
     ---> bae7de7b46f7
    Step 5 : RUN wget
     ---> Using cache
     ---> 245f6b6ceb84
     ---> 77532c879864
    Step 6 : RUN sha256sum -c SHASUM256.txt 2>&1|grep -qs OK
     ---> Running in 77765e80f55b
    2014/04/22 22:27:32 The command [/bin/sh -c sha256sum -c SHASUM256.txt 2>&1|grep -qs OK] returned a non-zero code: 1

    I tried adding less SHASUMS256.txt to the Dockerfile just to confirm that file is successfully downloaded uncorrupted, and it is, but still getting the error anyway.

    I’m not sure how to troubleshoot this since normally I would just manually run all the steps in an interactive container to see what goes wrong. Any suggestions much appreciated.

  • Docker Remote API returns 500 error on create container
  • Docker Run command hangs
  • docker stack deploy using the client api
  • Starting Xserver in Docker Ubuntu container
  • volume not getting mounted in nginx container
  • Docker: multiple PHP7-FPM containers on different ports
  • One Solution collect form web for “Dockerfile works when every line run interactively, but fails using docker build”

    I think I figured this out and it’s just a typo, at least when I cut and paste your commands above! You download SHASUMS256.txt but test against a file called SHASUM256.txt (missing the S). Because you throw away the output and pipe it to grep, you weren’t seeing that error.

    $ sha256sum -c SHASUM256.txt 
    sha256sum: SHASUM256.txt: No such file or directory
    $ sha256sum -c SHASUM256.txt 2>&1|grep -qs OK
    $ echo $?

    Doing an echo $? tells you the return code of the last command executed (in this case 1). By correcting the file, it works for me now:

     $ sha256sum -c SHASUMS256.txt 2>&1|grep -qs OK
     $ echo $?
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.