title: sha256 of locally built docker image
body: <p>How do I get the sha256 checksum of an already locally built docker image?</p>
  
  <p>I want to use the checksum to annotate a <code>FROM</code> instruction in a derived image:</p>
  
  <pre><code>FROM name@sha256:checksum
  </code></pre>
  
  <p>I already tried checksums from <code>docker inspect</code>.</p>
  
  <ul>
  <li>Neither the first nor the last of the checksums in the <code>Layers</code> list worked.</li>
  <li>The one in <code>"Id"</code> did not work.</li>
  <li>The one in <code>"Parent"</code> did not work.</li>
  <li>The one in <code>"Container"</code> did not work.</li>
  <li>The one in <code>"Image"</code> did not work.</li>
  </ul>
  
  <p>Some of them I only tried out of desperation to finally find the correct checksum for my docker image, but I cannot find the correct checksum. Only thing I did not try yet, because of the number of layers, is to go through <em>all</em> of the layers in case they are in a random order. But to put them there like that would not make sense to begin with.</p>
  
  <p>The error I see when I run <code>docker build -t &lt;some name&gt; .</code> in the directory of the Dockerfile of the derived image when it is not working is:</p>
  
  <pre><code>Step 1/7 : FROM name@sha256:&lt;checksum&gt; repository name not found: does not exist or no pull access
  </code></pre>
  
  <h1>Info</h1>
  
  <ul>
  <li>Docker version: <code>Docker version 17.05.0-ce, build 89658be</code> (obtained via <code>docker --version</code>)</li>
  <li><p>Output of <code>docker info</code>:</p>
  
  <pre><code>Containers: 0
   Running: 0
   Paused: 0
   Stopped: 0
  Images: 3841
  Server Version: 17.05.0-ce
  Storage Driver: aufs
   Root Dir: /var/lib/docker/aufs
   Backing Filesystem: extfs
   Dirs: 2620
   Dirperm1 Supported: true
  Logging Driver: json-file
  Cgroup Driver: cgroupfs
  Plugins: 
   Volume: local
   Network: bridge host macvlan null overlay
  Swarm: inactive
  Runtimes: runc
  Default Runtime: runc
  Init Binary: docker-init
  containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
  runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
  init version: 949e6fa
  Security Options:
   apparmor
   seccomp
    Profile: default
  Kernel Version: 4.4.0-78-generic
  Operating System: Ubuntu 16.04.2 LTS
  OSType: linux
  Architecture: x86_64
  CPUs: 4
  Total Memory: 7.684GiB
  Name: xiaolong-hp-pavilion
  ID: QCJS:JPK4:KC7J:6MYF:WWCA:XQM2:7AF7:HWWI:BRZK:GT6B:D2NP:OJFS
  Docker Root Dir: /var/lib/docker
  Debug Mode (client): false
  Debug Mode (server): false
  Registry: https://index.docker.io/v1/
  Experimental: false
  Insecure Registries:
   127.0.0.0/8
  Live Restore Enabled: false
  
  WARNING: No swap limit support
  </code></pre></li>
  </ul>