зеркало из https://github.com/microsoft/docker.git
Move commands into docker
This commit is contained in:
Родитель
b97f9e8148
Коммит
e5e66716df
|
@ -1,4 +1,4 @@
|
||||||
package commands
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
@ -6,7 +6,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker"
|
|
||||||
"github.com/dotcloud/docker/fs"
|
"github.com/dotcloud/docker/fs"
|
||||||
"github.com/dotcloud/docker/future"
|
"github.com/dotcloud/docker/future"
|
||||||
"github.com/dotcloud/docker/rcli"
|
"github.com/dotcloud/docker/rcli"
|
||||||
|
@ -550,7 +549,7 @@ func (srv *Server) CmdPs(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
if !*quiet {
|
if !*quiet {
|
||||||
command := fmt.Sprintf("%s %s", container.Path, strings.Join(container.Args, " "))
|
command := fmt.Sprintf("%s %s", container.Path, strings.Join(container.Args, " "))
|
||||||
if !*fl_full {
|
if !*fl_full {
|
||||||
command = docker.Trunc(command, 20)
|
command = Trunc(command, 20)
|
||||||
}
|
}
|
||||||
for idx, field := range []string{
|
for idx, field := range []string{
|
||||||
/* ID */ container.Id,
|
/* ID */ container.Id,
|
||||||
|
@ -741,10 +740,10 @@ func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string
|
||||||
return errors.New("No such container: " + cmd.Arg(0))
|
return errors.New("No such container: " + cmd.Arg(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) CreateContainer(img *fs.Image, ports []int, user string, tty bool, openStdin bool, memory int64, comment string, cmd string, args ...string) (*docker.Container, error) {
|
func (srv *Server) CreateContainer(img *fs.Image, ports []int, user string, tty bool, openStdin bool, memory int64, comment string, cmd string, args ...string) (*Container, error) {
|
||||||
id := future.RandomId()[:8]
|
id := future.RandomId()[:8]
|
||||||
container, err := srv.containers.Create(id, cmd, args, img,
|
container, err := srv.containers.Create(id, cmd, args, img,
|
||||||
&docker.Config{
|
&Config{
|
||||||
Hostname: id,
|
Hostname: id,
|
||||||
Ports: ports,
|
Ports: ports,
|
||||||
User: user,
|
User: user,
|
||||||
|
@ -945,12 +944,12 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() (*Server, error) {
|
func NewServer() (*Server, error) {
|
||||||
future.Seed()
|
future.Seed()
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
// }
|
// }
|
||||||
containers, err := docker.New()
|
containers, err := New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1001,6 +1000,6 @@ func (srv *Server) CmdWeb(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
containers *docker.Docker
|
containers *Docker
|
||||||
images *fs.Store
|
images *fs.Store
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/dotcloud/docker"
|
"github.com/dotcloud/docker"
|
||||||
"github.com/dotcloud/docker/commands"
|
|
||||||
"github.com/dotcloud/docker/future"
|
"github.com/dotcloud/docker/future"
|
||||||
"github.com/dotcloud/docker/rcli"
|
"github.com/dotcloud/docker/rcli"
|
||||||
"github.com/dotcloud/docker/term"
|
"github.com/dotcloud/docker/term"
|
||||||
|
@ -36,7 +35,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func daemon() error {
|
func daemon() error {
|
||||||
service, err := commands.New()
|
service, err := docker.NewServer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -78,7 +77,7 @@ func runCommand(args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
service, err := commands.New()
|
service, err := docker.NewServer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче