nlf / dhyve-os

a tiny OS for running docker in xhyve
194 stars 19 forks source link

Makefile fails to parse timestamp from `docker inspect` output #7

Closed amcinnes closed 8 years ago

amcinnes commented 8 years ago

These lines in the Makefile:

    $(eval STR_CREATED=$$(shell docker inspect -f '{{.Created}}' $(BUILD_IMAGE) 2>/dev/null))
    $(eval IMG_CREATED=$$(shell date -j -u -f "%F %T" "$$(STR_CREATED)" +"%s" 2>/dev/null \
        || echo 0))

are supposed to get the created timestamp of the image. But on my system, docker inspect returns an ISO 8601 time stamp like 2015-12-24T08:18:59.927830094Z, and that doesn't match %F %T. (%FT%T works.)

Does %F %T work for others? Is the problem specific to my Docker version?

$ docker inspect -f '{{.Created}}' dhyve-os-builder
2015-12-24T08:18:59.927830094Z

$ date -j -u -f "%F %T" "2015-12-24T08:18:59.927830094Z" +"%s"
Failed conversion of ``2015-12-24T08:18:59.927830094Z'' using format ``%F %T''
date: illegal time format
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

$ date -j -u -f "%FT%T" "2015-12-24T08:18:59.927830094Z" +"%s"
Warning: Ignoring 11 extraneous characters in date string (.927830094Z)
1450945139

$ docker version
Client:
 Version:      1.8.2
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   0a8c2e3
 Built:        Thu Sep 10 19:10:10 UTC 2015
 OS/Arch:      darwin/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64
ailispaw commented 8 years ago

Date format in docker inspect has been changed since 1.8.x. As you suggested, %FT%T should be fine.

ailispaw commented 8 years ago

@amcinnes Thank you for the heads up. I create a RP for this.

amcinnes commented 8 years ago

The PR seems to have fixed the issue.