docr
forked from marghidanu/docrdocr
Docker client for Crystal.
Full API description can be found here
Description
Remaining issues:
- Test all endpoint functions
- Make sure models are complete
- Extend client to support calls over network
PRs are always welcomed!
Installation
-
Add the dependency to your
shard.yml
:dependencies: docr: github: marghidanu/docr
-
Run
shards install
Usage
require "docr"
# Interacting with docker engine can be done through the docker engine API client, or a
# (considerably less feature rich for now) commands interface that models more closely
# the docker cli.
# API example
api = Docr::API.new
# downloads the image, second argument can be used to specify tag
api.images.create("alpine")
config = Docr::Types::CreateContainerConfig.new(
image: "alpine:latest",
env: ["ENVVAR=one"],
host_config: Docr::Types::HostConfig.new(
auto_remove: true
)
)
api.containers.create("my-alpine-container", config)
api.containers.start("my-alpine-container")
# stop the container
api.containers.stop("my-alpine-container")
# delete the container (if auto_remove isn't true)
api.containers.delete("my-alpine-container")
# Command example
# All commands follow the builder pattern, with each intermediate call just adding configurations,
# and the `execute` method "building" and running the actual call.
Docr.commands.run
.image("alpine:latest")
.env("ENVVAR", "one")
.name("my-alpine-container")
.rm # or .auto_remove
.execute
# stop the container
Docr.commands.stop
.name("my-alpine-container")
.execute
# delete the container (if auto_remove isn't true)
Docr.commands.rm
.name("my-alpine-container")
.execute
Supported API calls
Containers
- ContainerList
- ContainerCreate
- ContainerInspect
- ContainerTop
- ContainerLogs
- ContainerChanges
- ContainerStats
- ContainerStart
- ContainerStop
- ContainerRestart
- ContainerKill
- ContainerUpdate
- ContainerRename
- ContainerPause
- ContainerUnpause
- ContainerAttach
- ContainerWait
- ContainerDelete
Images
- ImageList
- ImageBuild
- ImageCreate
- ImageInspect
- ImageHistory
- ImagePush
- ImageTag
- ImageDelete
Networks
- NetworkList
- NetworkCreate
- NetworkInspect
- NetworkConnect
- NetworkDisconnect
- NetworkDelete
Volumes
- VolumeList
- VolumeCreate
- VolumeInspect
- VolumeDelete
Exec
- ContainerExec
- ExecStart
- ExecInspect
System
- SystemAuth
- SystemInfo
- SystemVersion
- SystemPing
- SystemEvents
- SystemDataUsage
Contributors
- Tudor Marghidanu - creator and maintainer
- Troy Sornson - contributor
Repository
docr
Owner
Statistic
- 0
- 0
- 0
- 1
- 0
- over 3 years ago
- July 13, 2021
License
MIT License
Links
Synced at
Sun, 24 Nov 2024 13:33:06 GMT
Languages