docker image unwind

To se all the commands that went into an image use a magic_bash function

function dc_trace_cmd() {
  local parent=`docker inspect -f '{{ .Parent }}' $1` 2>/dev/null
  declare -i level=$2
  echo ${level}: `docker inspect -f '{{ .ContainerConfig.Cmd }}' $1 2>/dev/null`
  level=level+1
  if [ "${parent}" != "" ]; then
    echo ${level}: $parent 
    dc_trace_cmd $parent $level
  fi
}

So with your dock image of 12345678

dc_trace_cmd 12345678

Which will output

0: [/bin/sh -c #(nop) CMD ["/usr/lib/postgresql/9.5/bin/postgres" "-D" "/var/lib/postgresql/9.5/main" "-c" "config_file=/etc/postgresql/9.5/main/postgresql.conf"]]
1: sha256:86db8bc2eaca871bd78ce11d0923c184a9521d6fa6d5c7e19671b90f20b687ad
1: [/bin/sh -c service postgresql start && cd /mnt/data && sleep 5s && osm2pgsql -C 8000 --slim --number-processes 4 -c -d gis_db gcc-states-latest.osm.pbf]
2: sha256:b73f7e83c1f18fd45084bfa60ed2eaf32dca058dbb22b0178c50d6b32c3d2c7c
2: [/bin/sh -c #(nop) ADD file:6924cc9504bc6128f21ef4b1461a513811cf67c260fd8b1976b1b2826d0e706e in /mnt/data/ ]
3: sha256:789e89e48c6af0cc9eaf8f70d35c2c480f5a5596cf35295c4d4e0fea8f6cadcf
3: [/bin/sh -c #(nop) VOLUME [/etc/postgresql /var/log/postgresql /var/lib/postgresql]]
4: sha256:48ffed30f1e37812081229ba3bf02d706048453918ddc4e8f060c6d9bf0fd7b1
4: [/bin/sh -c #(nop) EXPOSE 5432]
5: sha256:63e2035c27b2bdbb0e59341073a3fb1872f758881a4085d642c65513c25fbc60
5: [/bin/sh -c echo "listen_addresses='*'" >> /etc/postgresql/9.5/main/postgresql.conf]
6: sha256:df1ff130f56aa83f497079c4f085230f3f5f0d216508a54ea7bd4e1243c83939
6: [/bin/sh -c echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.5/main/pg_hba.conf]
7: sha256:3fe8add68e27502899d893ad924e8e3b3eed8d8ed35dddf3f14bd2be33910547
7: [/bin/sh -c echo "CREATE USER gis WITH SUPERUSER PASSWORD 'gispass';" > /tmp/ps.sh && echo "create database gis_db with owner=gis;" >> /tmp/ps.sh && service postgresql start && sleep 5s && cat /tmp/ps.sh && sleep 2s && cat /tmp/ps.sh | psql && echo "create extension \"postgis\";" | psql -d gis_db]
8: sha256:0f04d5b59f11692c4e4fbab9d0608f28f6615e01ce5f65e1276322e690d05e2f
8: [/bin/sh -c #(nop) USER postgres]
9: sha256:97fd8609bb05f90805939986e17002e5fffe1afaa947f785190096795b4d68b5
9: [/bin/sh -c apt-get install -y osm2pgsql]
10: sha256:2d6cf32f8840680b842f1c4f450bfd61f36628b425e7f07a16727d939b39ebad
10: [/bin/sh -c mkdir /mnt/data && chown postgres /mnt/data]
11: sha256:94912a2626b46375c4d80d077f9a8836360adb2101b75f88bd010b651baa927a
11: [/bin/sh -c apt-get install -y postgresql-client postgresql postgresql-contrib]
12: sha256:988bc2734968be5e1331ca31b33c689aa6719d17f9dc9559223373a789e72e93
12: [/bin/sh -c apt-get update -y]
13: sha256:0b1edfbffd27c935a666e233a0042ed634205f6f754dbe20769a60369c614f85
13: [/bin/sh -c #(nop) CMD ["/bin/bash"]]

This can be cleaned up a little