Skip to content

Instantly share code, notes, and snippets.

@duglin
duglin / findCommon
Created May 7, 2015 14:21
findCommon
package main
import (
"fmt"
"path/filepath"
"strings"
)
func findCommon(paths []string) string {
sep := string(filepath.Separator)
func GetTimestamp(value string) string {
format := RFC3339NanoFixed
loc := time.FixedZone(time.Now().Zone())
if len(value) < len(format) {
format = format[:len(value)]
}
var shift time.Duration
if i := strings.Index(value, "Z"); i > 0 && i != len(value)-1 {
parts := strings.SplitN(value[i+1:], ":", 2)
package main
import (
"fmt"
)
type ErrorCode struct {
code int
next *ErrorCode
}
In container:
/tmp/f1
/tmp/f2
/tmp/dir/f1
/tmp/dir/f2
CMD: docker cp container:source target
Source Target Body (tar unless otherwise indicated) Stat Hdr Result
/tmp . tmp + tmp/f1, tmp/f2, tmp/dir/f1, tmp/dir/f2 tmp stat ./tmp/...
@duglin
duglin / gist:a1a139791972e4cad37c
Last active August 29, 2015 14:22
Docker Deprecation Policy
PR Branch: https://github.com/duglin/docker/tree/Deprecate
Right now Docker's development is a bit constrained by the requirement to be backwards compatible.
Normally minor releases (e.g. 1.2 -> 1.3) are required to be backwards compatible, and that makes
a lot of sense for stable products that have a regular major release update schedule.
However, Docker is still (relatively) new and as such some of the original design decisions are
no longer correct, but we are forced to support them for, what feels like, forever. In addition,
there are cases where we decline to offer a better alternative because we would then feel
compelled to support both forever - and usually having more than one way to do something is bad.
Usage: docker [OPTIONS] COMMAND [arg...]
docker daemon [arg...]
docker [ -h | --help | -v | --version ]
A self-sufficient runtime for containers.
Options:
--config=~/.docker Location of client config files
-D, --debug=false Enable debug mode
-H, --host=[] Daemon socket(s) to connect to
tl;dr:
- Each unique error message that flows on the wire should use the error processing package.
- This means each unique error message will have a unique ID associated with it.
- Errors generated by libraries, non-Docker-specific code or that are not seen on the wire
can/should continue to use the standard go-lang error mechanisms.
Meaning: strings, types, etc... e.g. https://golang.org/src/os/file.go - line 84
- Each error, defined using the error processing package, will be self-describing. Which includes:
- unique ID
- error text
- descriptive text
FROM ubuntu
ENV foo=bar
RUN asdasd || echo hi
RUN 123
$ docker build . > out 2> err
$ cat out
Sending build context to Docker daemon 40.09 MB
$ docker rmi sha256:7b521
Error response from daemon: unrecognized image ID sha256:7b521
Error: failed to remove images: [sha256:7b521]
$ docker rmi 7b521
Deleted: sha256:7b521c3b64737ed5e5fe1b92c451a980fea823e6af8b020979a26fc09582b977
Deleted: sha256:94c29bb0663a983ac21bd7b4c9b6d18977a2cc16eaba846fa9d58738d118680c
diff --git a/daemon/daemon.go b/daemon/daemon.go
index 6a8d18e..f82bcdb 100644
--- a/daemon/daemon.go
+++ b/daemon/daemon.go
@@ -1236,6 +1236,10 @@ func (daemon *Daemon) ImageHistory(name string) ([]*types
// GetImageID returns an image ID corresponding to the image referred to by
// refOrID.
func (daemon *Daemon) GetImageID(refOrID string) (image.ID, error) {
+ if i := strings.Index(refOrID, ":"); i >= 0 {
+ refOrID = refOrID[i+1:]