Skip to content

shykes/docker2dagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

virtual-docker

Virtual-docker is a simple boilerplate mock Docker Engine API Server whose methods can be edited to implement all or parts of the Docker API.

It should compile on platforms where the Docker Engine does not run natively, such as MacOS.

To play with it you can either look at the simple test, or use the CLI.

Go test

go test

See main_test.go.

Docker CLI

Start API server:

$ go run github.com/tiborvass/virtual-docker &

Partially implemented endpoints

$ docker -H unix://docker.sock version
Client:
 Cloud integration: v1.0.22
 Version:           20.10.12
 API version:       1.24
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:46:56 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:
  API version:       (minimum version )
  Go version:
  Git commit:
  Built:
  OS/Arch:          /
  Experimental:     false
$ docker -H unix://docker.sock info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.7.1)
  compose: Docker Compose (Docker Inc., v2.2.3)
  scan: Docker Scan (Docker Inc., v0.17.0)
  wasm: Run wasm containers (Docker Inc.)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Plugins:
  Volume:
  Network:
  Log:
 Swarm:
  NodeID:
  Is Manager: false
  Node Address:
 CPUs: 0
 Total Memory: 0B
 Docker Root Dir:
 Debug Mode: false
 Experimental: false
 Live Restore Enabled: false

WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No cpu shares support
WARNING: No cpuset support
WARNING: IPv4 forwarding is disabled
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

Routed but not implemented endpoints

$ docker -H unix://docker.sock run busybox
2022/11/11 12:54:38 http: panic serving : not implemented
goroutine 23 [running]:
net/http.(*conn).serve.func1()
        net/http/server.go:1825 +0xbf
panic({0x148e4e0, 0xc000111c00})
        runtime/panic.go:844 +0x258
main.(*mockAPI).ContainerCreate(0x1018f0b?, {0x1c65100?, 0x1?}, {{0x0, 0x0}, 0xc0000a6140, 0xc0000dad80, 0xc0000105f8, 0x0, 0x1})
        github.com/tiborvass/virtual-docker/container.go:33 +0x45
github.com/docker/docker/api/server/router/container.(*containerRouter).postContainersCreate(0xc000112dc0, {0x15d6f18, 0xc00008c120}, {0x15d69f0, 0xc000090000}, 0xc0000a4200, 0x15d1870?)
        github.com/docker/docker@v20.10.18+incompatible/api/server/router/container/container_routes.go:580 +0x728
github.com/docker/docker/api/server.(*Server).makeHTTPHandler.func1({0x15d69f0, 0xc000090000}, 0xc0000a4100)
        github.com/docker/docker@v20.10.18+incompatible/api/server/server.go:144 +0x2fa
net/http.HandlerFunc.ServeHTTP(0xc0000a4000?, {0x15d69f0?, 0xc000090000?}, 0x0?)
        net/http/server.go:2084 +0x2f
github.com/gorilla/mux.(*Router).ServeHTTP(0xc0001940c0, {0x15d69f0, 0xc000090000}, 0xc0001bab00)
        github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0x15d58e8?}, {0x15d69f0, 0xc000090000}, 0xc0001bab00)
        net/http/server.go:2916 +0x43b
net/http.(*conn).serve(0xc0002d8460, {0x15d6f18, 0xc0002b9bc0})
        net/http/server.go:1966 +0x5d7
created by net/http.(*Server).Serve
        net/http/server.go:3071 +0x4db
docker: error during connect: Post "http://docker.sock/v1.24/containers/create": EOF.
See 'docker run --help'.

Endpoints not even routed

$ docker -H unix://docker.sock pull busybox
Using default tag: latest
Error response from daemon: page not found

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages