Compare commits

..

27 Commits

Author SHA1 Message Date
Sam Alba 222c04a7e7 Merge pull request #154 from dotcloud/153-commitnorepo
Clearer information when listing images
2013-03-25 12:04:57 -07:00
shin- c8ca50b483 Fixed issue #158 (docker crashes when docker run is called with not enough arguments) 2013-03-25 07:17:11 -07:00
Guillaume J. Charmes a61e68275a Merge branch 'master' of github.com:dotcloud/docker 2013-03-25 01:29:09 -07:00
Guillaume J. Charmes 6576b19a28 Improve the debug function 2013-03-25 01:29:01 -07:00
Guillaume J. Charmes ceb66fd035 Merge pull request #152 from srid/patch-1
`docker import` doesn't download an image
2013-03-24 16:58:35 -07:00
Guillaume J. Charmes 22598ee572 Merge pull request #155 from sa2ajj/debian-control-fix
fix run-time dependency
2013-03-24 16:54:01 -07:00
Guillaume J. Charmes 52969416bc Merge pull request #147 from dotcloud/146_autologin-feature
#146 Auto login on push
2013-03-24 16:52:50 -07:00
Mikhail Sobolev c61172f9c2 fix run-time dependency 2013-03-25 01:36:59 +02:00
shin- 0786d9ec22 Show <none> instead of an empty string in docker images listing for images with no repository or tag 2013-03-24 15:01:41 -07:00
shin- 938bf4c901 Reverted previous change 2013-03-24 14:53:00 -07:00
shin- 87d4e16568 Quick fix to avoid creating empty-string repositories when committing 2013-03-24 14:38:10 -07:00
Sridhar Ratnakumar 55c8908756 docker import doesn't download an image
```
$ docker import base
Downloading from http://base
Error: Get http://base: lookup base: no such host
```
only `docker pull` does:

```
$ docker pull base
Pulling base...
Pulling repo: https://registry.docker.io/v1/users/base
Pull completed
```
2013-03-24 14:13:08 -07:00
Guillaume J. Charmes 51455b1ee0 Merge pull request #138 from srid/handle-port-mapper-error
handle errors during the creation of port mapper
2013-03-24 10:27:03 -07:00
Ken Cochrane 906626b8f8 Merge pull request #143 from dotcloud/141-142_update_help-fix
141 142 update help fix
2013-03-24 07:07:24 -07:00
Guillaume J. Charmes e09383bccf Remove json alteration 2013-03-23 14:54:18 -07:00
Sridhar Ratnakumar 371225520f handle errors during the creation of port mapper
example:

  2013/03/22 21:42:55 Unable to setup port networking: Failed to create DOCKER chain

  (which was possibly introduced by commit 3c6b8bb88)
2013-03-22 21:44:01 -07:00
Guillaume J. Charmes eb95e49150 #146 Auto login on push 2013-03-22 19:04:12 -07:00
Guillaume J. Charmes 96010e3ca1 Allow anonymous pulls 2013-03-22 18:46:47 -07:00
Guillaume J. Charmes e55b8b2fd9 Merge pull request #145 from dotcloud/144-login_daemon_mode-fix
Login now works with daemon mode
2013-03-23 20:30:19 -07:00
Guillaume J. Charmes ffe5370e35 Login now works with daemon mode 2013-03-22 18:37:53 -07:00
Guillaume J. Charmes df19863b23 #142 Change the help for push and pull in order for it to be more clear 2013-03-22 18:17:49 -07:00
Guillaume J. Charmes cb3c4af404 #141 Update and order the help 2013-03-22 18:15:44 -07:00
Guillaume J. Charmes bd2a55cd26 Merge branch 'no_root_repo_push' 2013-03-22 17:58:34 -07:00
Guillaume J. Charmes b370acd679 Forbid users to push "root" repositories 2013-03-22 17:58:00 -07:00
Guillaume J. Charmes 5c04d3488a Implement the "library" repository endpoint on the registry 2013-03-22 17:43:11 -07:00
Solomon Hykes 0d46ddf7b4 'docker commit -m': optional commit message 2013-03-23 19:16:42 -07:00
Solomon Hykes f7eaaa3adb Clean up 'container' environment variable injected by lxc-start 2013-03-23 19:11:00 -07:00
9 changed files with 82 additions and 28 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ Running an interactive shell
```bash
# Download a base image
docker import base
docker pull base
# Run an interactive shell in the base image,
# allocate a tty, attach stdin and stdout
+22 -17
View File
@@ -30,14 +30,13 @@ func (srv *Server) Name() string {
func (srv *Server) Help() string {
help := "Usage: docker COMMAND [arg...]\n\nA self-sufficient runtime for linux containers.\n\nCommands:\n"
for _, cmd := range [][]interface{}{
{"run", "Run a command in a container"},
{"ps", "Display a list of containers"},
{"import", "Create a new filesystem image from the contents of a tarball"},
{"attach", "Attach to a running container"},
{"commit", "Create a new image from a container's changes"},
{"history", "Show the history of an image"},
{"diff", "Inspect changes on a container's filesystem"},
{"export", "Stream the contents of a container as a tar archive"},
{"history", "Show the history of an image"},
{"images", "List images"},
{"import", "Create a new filesystem image from the contents of a tarball"},
{"info", "Display system-wide information"},
{"inspect", "Return low-level information on a container"},
{"kill", "Kill a running container"},
@@ -53,7 +52,7 @@ func (srv *Server) Help() string {
{"run", "Run a command in a new container"},
{"start", "Start a stopped container"},
{"stop", "Stop a running container"},
{"export", "Stream the contents of a container as a tar archive"},
{"tag", "Tag an image into a repository"},
{"version", "Show the docker version information"},
{"wait", "Block until a container stops, then print its exit code"},
} {
@@ -98,6 +97,8 @@ func (srv *Server) CmdLogin(stdin io.ReadCloser, stdout io.Writer, args ...strin
status, err := auth.Login(newAuthConfig)
if err != nil {
fmt.Fprintf(stdout, "Error : %s\n", err)
} else {
srv.runtime.authConfig = newAuthConfig
}
if status != "" {
fmt.Fprintf(stdout, status)
@@ -400,7 +401,7 @@ func (srv *Server) CmdImport(stdin io.ReadCloser, stdout io.Writer, args ...stri
}
func (srv *Server) CmdPush(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
cmd := rcli.Subcmd(stdout, "push", "LOCAL", "Push an image or a repository to the registry")
cmd := rcli.Subcmd(stdout, "push", "NAME", "Push an image or a repository to the registry")
if err := cmd.Parse(args); err != nil {
return nil
}
@@ -412,15 +413,22 @@ func (srv *Server) CmdPush(stdin io.ReadCloser, stdout io.Writer, args ...string
}
// If the login failed, abort
if srv.runtime.authConfig == nil {
return fmt.Errorf("Please login prior to push. ('docker login')")
if srv.runtime.authConfig == nil || srv.runtime.authConfig.Username == "" {
if err := srv.CmdLogin(stdin, stdout, args...); err != nil {
return err
}
if srv.runtime.authConfig == nil || srv.runtime.authConfig.Username == "" {
return fmt.Errorf("Please login prior to push. ('docker login')")
}
}
var remote string
tmp := strings.SplitN(local, "/", 2)
if len(tmp) == 1 {
remote = srv.runtime.authConfig.Username + "/" + local
return fmt.Errorf(
"Impossible to push a \"root\" repository. Please rename your repository in <user>/<repo> (ex: %s/%s)",
srv.runtime.authConfig.Username, local)
} else {
remote = local
}
@@ -458,7 +466,7 @@ func (srv *Server) CmdPush(stdin io.ReadCloser, stdout io.Writer, args ...string
}
func (srv *Server) CmdPull(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
cmd := rcli.Subcmd(stdout, "pull", "IMAGE", "Pull an image or a repository from the registry")
cmd := rcli.Subcmd(stdout, "pull", "NAME", "Pull an image or a repository from the registry")
if err := cmd.Parse(args); err != nil {
return nil
}
@@ -468,10 +476,6 @@ func (srv *Server) CmdPull(stdin io.ReadCloser, stdout io.Writer, args ...string
return nil
}
if srv.runtime.authConfig == nil {
return fmt.Errorf("Please login prior to push. ('docker login')")
}
if srv.runtime.graph.LookupRemoteImage(remote, srv.runtime.authConfig) {
fmt.Fprintf(stdout, "Pulling %s...\n", remote)
if err := srv.runtime.graph.PullImage(remote, srv.runtime.authConfig); err != nil {
@@ -555,8 +559,8 @@ func (srv *Server) CmdImages(stdin io.ReadCloser, stdout io.Writer, args ...stri
for id, image := range allImages {
if !*quiet {
for idx, field := range []string{
/* REPOSITORY */ "",
/* TAG */ "",
/* REPOSITORY */ "<none>",
/* TAG */ "<none>",
/* ID */ id,
/* CREATED */ HumanDuration(time.Now().Sub(image.Created)) + " ago",
/* PARENT */ srv.runtime.repositories.ImageName(image.Parent),
@@ -630,6 +634,7 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
cmd := rcli.Subcmd(stdout,
"commit", "[OPTIONS] CONTAINER [REPOSITORY [TAG]]",
"Create a new image from a container's changes")
fl_comment := cmd.String("m", "", "Commit message")
if err := cmd.Parse(args); err != nil {
return nil
}
@@ -638,7 +643,7 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
cmd.Usage()
return nil
}
img, err := srv.runtime.Commit(containerName, repository, tag)
img, err := srv.runtime.Commit(containerName, repository, tag, *fl_comment)
if err != nil {
return err
}
+11 -2
View File
@@ -76,6 +76,15 @@ func ParseRun(args []string) (*Config, error) {
if err := cmd.Parse(args); err != nil {
return nil, err
}
parsedArgs := cmd.Args()
runCmd := []string{}
image := ""
if len(parsedArgs) >= 1 {
image = cmd.Arg(0)
}
if len(parsedArgs) > 1 {
runCmd = parsedArgs[1:]
}
config := &Config{
Ports: fl_ports,
User: *fl_user,
@@ -84,8 +93,8 @@ func ParseRun(args []string) (*Config, error) {
Memory: *fl_memory,
Detach: *fl_detach,
Env: fl_env,
Cmd: cmd.Args()[1:],
Image: cmd.Arg(0),
Cmd: runCmd,
Image: image,
}
return config, nil
}
+1 -1
View File
@@ -10,7 +10,7 @@ Standards-Version: 3.9.2
Package: dotcloud-docker
Architecture: amd64
Provides: dotcloud-docker
Depends: lxc, wget, bsdtar, curl, sqlite3
Depends: lxc, wget, bsdtar, curl, libsqlite3-0
Conflicts: docker
Description: A process manager with superpowers
It encapsulates heterogeneous payloads in Standard Containers, and runs
+3
View File
@@ -349,6 +349,9 @@ func newNetworkManager(bridgeIface string) (*NetworkManager, error) {
}
portMapper, err := newPortMapper()
if err != nil {
return nil, err
}
manager := &NetworkManager{
bridgeIface: bridgeIface,
+10 -2
View File
@@ -32,7 +32,7 @@ func NewImgJson(src []byte) (*Image, error) {
func NewMultipleImgJson(src []byte) ([]*Image, error) {
ret := []*Image{}
dec := json.NewDecoder(strings.NewReader(strings.Replace(string(src), "null", "\"\"", -1)))
dec := json.NewDecoder(strings.NewReader(string(src)))
for {
m := &Image{}
if err := dec.Decode(m); err == io.EOF {
@@ -164,7 +164,15 @@ func (graph *Graph) PullRepository(stdout io.Writer, remote, askedTag string, re
fmt.Fprintf(stdout, "Pulling repo: %s\n", REGISTRY_ENDPOINT+"/users/"+remote)
req, err := http.NewRequest("GET", REGISTRY_ENDPOINT+"/users/"+remote, nil)
var repositoryTarget string
// If we are asking for 'root' repository, lookup on the Library's registry
if strings.Index(remote, "/") == -1 {
repositoryTarget = REGISTRY_ENDPOINT + "/library/" + remote
} else {
repositoryTarget = REGISTRY_ENDPOINT + "/users/" + remote
}
req, err := http.NewRequest("GET", repositoryTarget, nil)
if err != nil {
return err
}
+2 -2
View File
@@ -181,7 +181,7 @@ func (runtime *Runtime) Destroy(container *Container) error {
// Commit creates a new filesystem image from the current state of a container.
// The image can optionally be tagged into a repository
func (runtime *Runtime) Commit(id, repository, tag string) (*Image, error) {
func (runtime *Runtime) Commit(id, repository, tag, comment string) (*Image, error) {
container := runtime.Get(id)
if container == nil {
return nil, fmt.Errorf("No such container: %s", id)
@@ -193,7 +193,7 @@ func (runtime *Runtime) Commit(id, repository, tag string) (*Image, error) {
return nil, err
}
// Create a new image from the container's base layers + a new layer from container changes
img, err := runtime.graph.Create(rwTar, container, "")
img, err := runtime.graph.Create(rwTar, container, comment)
if err != nil {
return nil, err
}
+18
View File
@@ -8,6 +8,7 @@ import (
"os/exec"
"os/user"
"strconv"
"strings"
"syscall"
)
@@ -52,6 +53,22 @@ func changeUser(u string) {
}
}
// Clear environment pollution introduced by lxc-start
func cleanupEnv() {
env := os.Environ()
os.Clearenv()
for _, kv := range env {
parts := strings.SplitN(kv, "=", 2)
if len(parts) == 1 {
parts = append(parts, "")
}
if parts[0] == "container" {
continue
}
os.Setenv(parts[0], parts[1])
}
}
func executeProgram(name string, args []string) {
path, err := exec.LookPath(name)
if err != nil {
@@ -78,6 +95,7 @@ func SysInit() {
flag.Parse()
setupNetworking(*gw)
cleanupEnv()
changeUser(*u)
executeProgram(flag.Arg(0), flag.Args())
}
+14 -3
View File
@@ -7,11 +7,12 @@ import (
"fmt"
"github.com/dotcloud/docker/rcli"
"io"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
)
@@ -43,9 +44,19 @@ func Download(url string, stderr io.Writer) (*http.Response, error) {
// If Docker is in damon mode, also send the debug info on the socket
func Debugf(format string, a ...interface{}) {
if rcli.DEBUG_FLAG {
log.Printf(format, a...)
// Retrieve the stack infos
_, file, line, ok := runtime.Caller(1)
if !ok {
file = "<unknown>"
line = -1
} else {
file = file[strings.LastIndex(file, "/")+1:]
}
fmt.Fprintf(os.Stderr, fmt.Sprintf("[debug] %s:%d %s\n", file, line, format), a...)
if rcli.CLIENT_SOCKET != nil {
fmt.Fprintf(rcli.CLIENT_SOCKET, log.Prefix()+format, a...)
fmt.Fprintf(rcli.CLIENT_SOCKET, fmt.Sprintf("[debug] %s:%d %s\n", file, line, format), a...)
}
}
}