Question

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.

Works:

docker run -i -t ubuntu:12.04 /bin/bash

cd /tmp

apt-get update -y

apt-get install wget build-essential automake -y

wget http://nodejs.org/dist/latest/node-v0.10.26.tar.gz

wget http://nodejs.org/dist/latest/SHASUMS256.txt

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 http://nodejs.org/dist/latest/node-v0.10.26.tar.gz
 ---> Using cache
 ---> bae7de7b46f7
Step 5 : RUN wget http://nodejs.org/dist/latest/SHASUMS256.txt
 ---> 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.

Was it helpful?

Solution

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 $?
1

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 $?
 0
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top