Skip to content

Commit

Permalink
Merge branch 'master' of github.com:docker/docker into journald
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
  • Loading branch information
rhatdan committed Apr 22, 2015
2 parents 364287b + 2926544 commit b88b2fa
Show file tree
Hide file tree
Showing 130 changed files with 8,734 additions and 5,202 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Under the hood, Docker is built on the following components:
Contributing to Docker
======================

[![GoDoc](https://godoc.org/github.com/docker/docker?status.png)](https://godoc.org/github.com/docker/docker)
[![GoDoc](https://godoc.org/github.com/docker/docker?status.svg)](https://godoc.org/github.com/docker/docker)
[![Jenkins Build Status](https://jenkins.dockerproject.com/job/Docker%20Master/badge/icon)](https://jenkins.dockerproject.com/job/Docker%20Master/)

Want to hack on Docker? Awesome! We have [instructions to help you get
Expand Down
7 changes: 7 additions & 0 deletions api/client/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func (cli *DockerCli) Cmd(args ...string) error {
return cli.CmdHelp()
}

// Subcmd is a subcommand of the main "docker" command.
// A subcommand represents an action that can be performed
// from the Docker command line client.
//
// To see all available subcommands, run "docker --help".
func (cli *DockerCli) Subcmd(name, signature, description string, exitOnError bool) *flag.FlagSet {
var errorHandling flag.ErrorHandling
if exitOnError {
Expand All @@ -121,6 +126,8 @@ func (cli *DockerCli) Subcmd(name, signature, description string, exitOnError bo
return flags
}

// CheckTtyInput checks if we are trying to attach to a container tty
// from a non-tty client input stream, and if so, returns an error.
func (cli *DockerCli) CheckTtyInput(attachStdin, ttyMode bool) error {
// In order to attach to a container tty, input stream for the client must
// be a tty itself: redirecting or piping the client standard input is
Expand Down
12 changes: 6 additions & 6 deletions api/client/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ import (
)

// FIXME: --viz and --tree are deprecated. Remove them in a future version.
func (cli *DockerCli) WalkTree(noTrunc bool, images []*types.Image, byParent map[string][]*types.Image, prefix string, printNode func(cli *DockerCli, noTrunc bool, image *types.Image, prefix string)) {
func (cli *DockerCli) walkTree(noTrunc bool, images []*types.Image, byParent map[string][]*types.Image, prefix string, printNode func(cli *DockerCli, noTrunc bool, image *types.Image, prefix string)) {
length := len(images)
if length > 1 {
for index, image := range images {
if index+1 == length {
printNode(cli, noTrunc, image, prefix+"└─")
if subimages, exists := byParent[image.ID]; exists {
cli.WalkTree(noTrunc, subimages, byParent, prefix+" ", printNode)
cli.walkTree(noTrunc, subimages, byParent, prefix+" ", printNode)
}
} else {
printNode(cli, noTrunc, image, prefix+"\u251C─")
if subimages, exists := byParent[image.ID]; exists {
cli.WalkTree(noTrunc, subimages, byParent, prefix+"\u2502 ", printNode)
cli.walkTree(noTrunc, subimages, byParent, prefix+"\u2502 ", printNode)
}
}
}
} else {
for _, image := range images {
printNode(cli, noTrunc, image, prefix+"└─")
if subimages, exists := byParent[image.ID]; exists {
cli.WalkTree(noTrunc, subimages, byParent, prefix+" ", printNode)
cli.walkTree(noTrunc, subimages, byParent, prefix+" ", printNode)
}
}
}
Expand Down Expand Up @@ -181,9 +181,9 @@ func (cli *DockerCli) CmdImages(args ...string) error {

if startImage != nil {
root := []*types.Image{startImage}
cli.WalkTree(*noTrunc, root, byParent, "", printNode)
cli.walkTree(*noTrunc, root, byParent, "", printNode)
} else if matchName == "" {
cli.WalkTree(*noTrunc, roots, byParent, "", printNode)
cli.walkTree(*noTrunc, roots, byParent, "", printNode)
}
if *flViz {
fmt.Fprintf(cli.out, " base [style=invisible]\n}\n")
Expand Down
3 changes: 3 additions & 0 deletions api/client/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
flag "github.com/docker/docker/pkg/mflag"
)

// CmdRm removes one or more containers.
//
// Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
func (cli *DockerCli) CmdRm(args ...string) error {
cmd := cli.Subcmd("rm", "CONTAINER [CONTAINER...]", "Remove one or more containers", true)
v := cmd.Bool([]string{"v", "-volumes"}, false, "Remove the volumes associated with the container")
Expand Down
1 change: 1 addition & 0 deletions api/client/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/docker/docker/registry"
)

// ByStars sorts search results in ascending order by number of stars.
type ByStars []registry.SearchResult

func (r ByStars) Len() int { return len(r) }
Expand Down
9 changes: 5 additions & 4 deletions api/client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ import (
)

var (
ErrConnectionRefused = errors.New("Cannot connect to the Docker daemon. Is 'docker -d' running on this host?")
errConnectionRefused = errors.New("Cannot connect to the Docker daemon. Is 'docker -d' running on this host?")
)

// HTTPClient creates a new HTP client with the cli's client transport instance.
func (cli *DockerCli) HTTPClient() *http.Client {
return &http.Client{Transport: cli.transport}
}
Expand Down Expand Up @@ -93,7 +94,7 @@ func (cli *DockerCli) clientRequest(method, path string, in io.Reader, headers m
}
if err != nil {
if strings.Contains(err.Error(), "connection refused") {
return nil, "", statusCode, ErrConnectionRefused
return nil, "", statusCode, errConnectionRefused
}

if cli.tlsConfig == nil {
Expand Down Expand Up @@ -250,7 +251,7 @@ func getExitCode(cli *DockerCli, containerID string) (bool, int, error) {
stream, _, err := cli.call("GET", "/containers/"+containerID+"/json", nil, nil)
if err != nil {
// If we can't connect, then the daemon probably died.
if err != ErrConnectionRefused {
if err != errConnectionRefused {
return false, -1, err
}
return false, -1, nil
Expand All @@ -271,7 +272,7 @@ func getExecExitCode(cli *DockerCli, execID string) (bool, int, error) {
stream, _, err := cli.call("GET", "/exec/"+execID+"/json", nil, nil)
if err != nil {
// If we can't connect, then the daemon probably died.
if err != ErrConnectionRefused {
if err != errConnectionRefused {
return false, -1, err
}
return false, -1, nil
Expand Down
16 changes: 4 additions & 12 deletions api/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,6 @@ func httpError(w http.ResponseWriter, err error) {
http.Error(w, err.Error(), statusCode)
}

// writeJSONEnv writes the engine.Env values to the http response stream as a
// json encoded body.
func writeJSONEnv(w http.ResponseWriter, code int, v engine.Env) error {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
return v.Encode(w)
}

// writeJSON writes the value v to the http response stream as json with standard
// json encoding.
func writeJSON(w http.ResponseWriter, code int, v interface{}) error {
Expand Down Expand Up @@ -716,7 +708,7 @@ func (s *Server) postCommit(eng *engine.Engine, version version.Version, w http.
Config: c,
}

imgID, err := builder.Commit(s.daemon, eng, cont, containerCommitConfig)
imgID, err := builder.Commit(s.daemon, cont, containerCommitConfig)
if err != nil {
return err
}
Expand Down Expand Up @@ -772,7 +764,7 @@ func (s *Server) postImagesCreate(eng *engine.Engine, version version.Version, w
imagePullConfig.Json = false
}

if err := s.daemon.Repositories().Pull(image, tag, imagePullConfig, eng); err != nil {
if err := s.daemon.Repositories().Pull(image, tag, imagePullConfig); err != nil {
return err
}
} else { //import
Expand All @@ -793,7 +785,7 @@ func (s *Server) postImagesCreate(eng *engine.Engine, version version.Version, w
imageImportConfig.Json = false
}

newConfig, err := builder.BuildFromConfig(s.daemon, eng, &runconfig.Config{}, imageImportConfig.Changes)
newConfig, err := builder.BuildFromConfig(s.daemon, &runconfig.Config{}, imageImportConfig.Changes)
if err != nil {
return err
}
Expand Down Expand Up @@ -1335,7 +1327,7 @@ func (s *Server) postBuild(eng *engine.Engine, version version.Version, w http.R
}()
}

if err := builder.Build(s.daemon, eng, buildConfig); err != nil {
if err := builder.Build(s.daemon, buildConfig); err != nil {
// Do not write the error in the http output if it's still empty.
// This prevents from writing a 200(OK) when there is an interal error.
if !output.Flushed() {
Expand Down
2 changes: 0 additions & 2 deletions builder/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/docker/docker/builder/command"
"github.com/docker/docker/builder/parser"
"github.com/docker/docker/daemon"
"github.com/docker/docker/engine"
"github.com/docker/docker/pkg/fileutils"
"github.com/docker/docker/pkg/streamformatter"
"github.com/docker/docker/pkg/stringid"
Expand Down Expand Up @@ -80,7 +79,6 @@ func init() {
// processing as it evaluates the parsing result.
type Builder struct {
Daemon *daemon.Daemon
Engine *engine.Engine

// effectively stdio for the run. Because it is not stdio, I said
// "Effectively". Do not use stdio anywhere in this package for any reason.
Expand Down
2 changes: 1 addition & 1 deletion builder/internals.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (b *Builder) pullImage(name string) (*imagepkg.Image, error) {
Json: b.StreamFormatter.Json(),
}

if err := b.Daemon.Repositories().Pull(remote, tag, imagePullConfig, b.Engine); err != nil {
if err := b.Daemon.Repositories().Pull(remote, tag, imagePullConfig); err != nil {
return nil, err
}

Expand Down
11 changes: 4 additions & 7 deletions builder/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/docker/docker/api"
"github.com/docker/docker/builder/parser"
"github.com/docker/docker/daemon"
"github.com/docker/docker/engine"
"github.com/docker/docker/graph"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/httputils"
Expand Down Expand Up @@ -83,7 +82,7 @@ func NewBuildConfig() *Config {
}
}

func Build(d *daemon.Daemon, e *engine.Engine, buildConfig *Config) error {
func Build(d *daemon.Daemon, buildConfig *Config) error {
var (
repoName string
tag string
Expand Down Expand Up @@ -150,7 +149,6 @@ func Build(d *daemon.Daemon, e *engine.Engine, buildConfig *Config) error {

builder := &Builder{
Daemon: d,
Engine: e,
OutStream: &streamformatter.StdoutFormater{
Writer: buildConfig.Stdout,
StreamFormatter: sf,
Expand Down Expand Up @@ -188,7 +186,7 @@ func Build(d *daemon.Daemon, e *engine.Engine, buildConfig *Config) error {
return nil
}

func BuildFromConfig(d *daemon.Daemon, e *engine.Engine, c *runconfig.Config, changes []string) (*runconfig.Config, error) {
func BuildFromConfig(d *daemon.Daemon, c *runconfig.Config, changes []string) (*runconfig.Config, error) {
ast, err := parser.Parse(bytes.NewBufferString(strings.Join(changes, "\n")))
if err != nil {
return nil, err
Expand All @@ -203,7 +201,6 @@ func BuildFromConfig(d *daemon.Daemon, e *engine.Engine, c *runconfig.Config, ch

builder := &Builder{
Daemon: d,
Engine: e,
Config: c,
OutStream: ioutil.Discard,
ErrStream: ioutil.Discard,
Expand All @@ -219,13 +216,13 @@ func BuildFromConfig(d *daemon.Daemon, e *engine.Engine, c *runconfig.Config, ch
return builder.Config, nil
}

func Commit(d *daemon.Daemon, eng *engine.Engine, name string, c *daemon.ContainerCommitConfig) (string, error) {
func Commit(d *daemon.Daemon, name string, c *daemon.ContainerCommitConfig) (string, error) {
container, err := d.Get(name)
if err != nil {
return "", err
}

newConfig, err := BuildFromConfig(d, eng, c.Config, c.Changes)
newConfig, err := BuildFromConfig(d, c.Config, c.Changes)
if err != nil {
return "", err
}
Expand Down
6 changes: 4 additions & 2 deletions daemon/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,13 @@ func (container *Container) readHostConfig() error {
return nil
}

data, err := ioutil.ReadFile(pth)
f, err := os.Open(pth)
if err != nil {
return err
}
return json.Unmarshal(data, container.hostConfig)
defer f.Close()

return json.NewDecoder(f).Decode(&container.hostConfig)
}

func (container *Container) WriteHostConfig() error {
Expand Down
30 changes: 15 additions & 15 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ type Daemon struct {
containerGraph *graphdb.Database
driver graphdriver.Driver
execDriver execdriver.Driver
trustStore *trust.TrustStore
statsCollector *statsCollector
defaultLogConfig runconfig.LogConfig
RegistryService *registry.Service
Expand All @@ -129,9 +128,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
if err := daemon.Repositories().Install(eng); err != nil {
return err
}
if err := daemon.trustStore.Install(eng); err != nil {
return err
}
// FIXME: this hack is necessary for legacy integration tests to access
// the daemon object.
eng.HackSetGlobalVar("httpapi.daemon", daemon)
Expand Down Expand Up @@ -194,8 +190,6 @@ func (daemon *Daemon) load(id string) (*Container, error) {
return container, fmt.Errorf("Container %s is stored at %s", container.ID, id)
}

container.readHostConfig()

return container, nil
}

Expand Down Expand Up @@ -903,22 +897,29 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine, registryService
return nil, err
}

eventsService := events.New()
logrus.Debug("Creating repository list")
repositories, err := graph.NewTagStore(path.Join(config.Root, "repositories-"+driver.String()), g, trustKey, registryService, eventsService)
if err != nil {
return nil, fmt.Errorf("Couldn't create Tag store: %s", err)
}

trustDir := path.Join(config.Root, "trust")
if err := os.MkdirAll(trustDir, 0700); err != nil && !os.IsExist(err) {
return nil, err
}
t, err := trust.NewTrustStore(trustDir)
trustService, err := trust.NewTrustStore(trustDir)
if err != nil {
return nil, fmt.Errorf("could not create trust store: %s", err)
}

eventsService := events.New()
logrus.Debug("Creating repository list")
tagCfg := &graph.TagStoreConfig{
Graph: g,
Key: trustKey,
Registry: registryService,
Events: eventsService,
Trust: trustService,
}
repositories, err := graph.NewTagStore(path.Join(config.Root, "repositories-"+driver.String()), tagCfg)
if err != nil {
return nil, fmt.Errorf("Couldn't create Tag store: %s", err)
}

if !config.DisableNetwork {
if err := bridge.InitDriver(&config.Bridge); err != nil {
return nil, fmt.Errorf("Error initializing Bridge: %v", err)
Expand Down Expand Up @@ -980,7 +981,6 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine, registryService
sysInitPath: sysInitPath,
execDriver: ed,
eng: eng,
trustStore: t,
statsCollector: newStatsCollector(1 * time.Second),
defaultLogConfig: config.LogConfig,
RegistryService: registryService,
Expand Down
2 changes: 1 addition & 1 deletion docs/man/docker-commit.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Using an existing container's name or ID you can create a new image.

**-c** , **--change**=[]
Apply specified Dockerfile instructions while committing the image
Supported Dockerfile instructions: `ADD`|`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`FROM`|`MAINTAINER`|`RUN`|`USER`|`LABEL`|`VOLUME`|`WORKDIR`|`COPY`
Supported Dockerfile instructions: `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`

**--help**
Print usage statement
Expand Down
2 changes: 1 addition & 1 deletion docs/man/docker-import.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ URL|- [REPOSITORY[:TAG]]
# OPTIONS
**-c**, **--change**=[]
Apply specified Dockerfile instructions while importing the image
Supported Dockerfile instructions: `ADD`|`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`FROM`|`MAINTAINER`|`RUN`|`USER`|`LABEL`|`VOLUME`|`WORKDIR`|`COPY`
Supported Dockerfile instructions: `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`

# DESCRIPTION
Create a new filesystem image from the contents of a tarball (`.tar`,
Expand Down
7 changes: 4 additions & 3 deletions docs/sources/reference/commandline/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,8 @@ If this behavior is undesired, set the 'p' option to false.

The `--change` option will apply `Dockerfile` instructions to the image
that is created.
Supported `Dockerfile` instructions: `ADD`|`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`FROM`|`MAINTAINER`|`RUN`|`USER`|`LABEL`|`VOLUME`|`WORKDIR`|`COPY`
Supported `Dockerfile` instructions:
`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`

#### Commit a container

Expand Down Expand Up @@ -1380,8 +1381,8 @@ the `-` parameter to take the data from `STDIN`.

The `--change` option will apply `Dockerfile` instructions to the image
that is created.
Supported `Dockerfile` instructions: `CMD`, `ENTRYPOINT`, `ENV`, `EXPOSE`,
`ONBUILD`, `USER`, `VOLUME`, `WORKDIR`
Supported `Dockerfile` instructions:
`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`

#### Examples

Expand Down
Loading

0 comments on commit b88b2fa

Please sign in to comment.