Swiftpack.co -  alexsteinerde/docker-client-swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
alexsteinerde/docker-client-swift
This is a Docker Client written in Swift. It's using the NIO Framework to communicate with the Docker Engine via sockets.
.package(url: "https://github.com/alexsteinerde/docker-client-swift.git", from: "0.1.0")

Docker Client

Language Docker Engine API

This is a Docker Client written in Swift. It's using the NIO Framework to communicate with the Docker Engine via sockets.

Current Use Cases

  • ☑ List of all images
  • ☑ List of all containers
  • ☑ Pull an image
  • ☑ Create a new container from an image
  • ☑ Start a container
  • ☑ Get the stdOut and stdErr output of a container
  • ☑ Get the docker version information
  • ☑ Manage the container state
  • ☑ Create and manage services
  • ☑ Update services
  • ☑ List services
  • ☑ Clean the system (prune containers and images)

Installation

Package.swift

import PackageDescription

let package = Package(
    dependencies: [
    .package(url: "https://github.com/alexsteinerde/docker-client-swift.git", from: "0.1.0"),
    ],
    targets: [
    .target(name: "App", dependencies: ["DockerClient"]),
    ...
    ]
)

Xcode Project

To add DockerClientSwift to your existing Xcode project, select File -> Swift Packages -> Add Package Depedancy. Enter https://github.com/alexsteinerde/docker-client-swift.git for the URL.

Usage Example

let client = DockerClient()
let image = try client.images.pullImage(imageName: "hello-world:latest").wait()
let container = try! client.containers.createContainer(image: image).wait()
try container.start(on: client).wait()
let output = try container.logs(on: client).wait()
print(output)

For further usage examples, please consider looking at the provided test cases. Or have a look at the demo projects in the next section. If you want to read more about this package, feel free to read my blog article about it.

Demo

There are two demo applications.

Project Link
Mac App https://github.com/alexsteinerde/docker-client-swift-mac-app
Vapor App https://github.com/alexsteinerde/docker-client-vapor-demo

Security Advice

When using this in production, make sure you secure your application so no others can execute code. Otherwise, the attacker could access your Docker environment and so all of the containers running in it.

License

This project is released under the MIT license. See LICENSE for details.

Contribution

You can contribute to this project by submitting a detailed issue or by forking this project and sending a pull request. Contributions of any kind are very welcome :)

GitHub

link
Stars: 9
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Initial Release
1 week ago

This is the initial release with a subset of the available APIs Docker provides.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API