https://github.com/perkss/docker-cpp
Docker Client for C++
https://github.com/perkss/docker-cpp
cmake cpp docker
Last synced: about 1 year ago
JSON representation
Docker Client for C++
- Host: GitHub
- URL: https://github.com/perkss/docker-cpp
- Owner: perkss
- License: apache-2.0
- Created: 2023-06-25T07:57:30.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-15T21:16:49.000Z (about 2 years ago)
- Last Synced: 2025-02-10T00:26:02.056Z (about 1 year ago)
- Topics: cmake, cpp, docker
- Language: C++
- Homepage:
- Size: 29.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# docker-cpp
Docker Client for C++.
## Introduction
The Docker Client for C++ is a client api for executing docker commands from C++.
## Contributions
Contributions are welcome please see the [Contributing.md](CONTRIBUTING.md).
## Dependencies
* spdlog
* curl
* boost
## Build
```
cmake --build build
cmake --build build -t test
```
## Getting Started
The tests folder contains many examples of using the docker client for c++ this is a great place to look.
```
dockercpp::DockerClient dockerclient;
// Pull an image named busybox with version 1.36
auto pulledImage =
dockerclient.pullImageCmd("busybox")->withTag("1.36").exec();
// Create the container with a name example and a command.
auto response = dockerclient.createContainerCmd("busybox:1.36")
->withName("example")
.withCmd(std::vector{"sleep", "9999"})
.exec();
auto startcontainer = dockerclient.startContainerCmd(response.id)->exec();
auto inspectcontainer = dockerclient.inspectContainerCmd(response.id)->exec();
auto stopcontainer = dockerclient.stopContainerCmd(response.id)->exec();
// Check the container status now it is stopped
auto inspectcontainerstopped =
dockerclient.inspectContainerCmd(response.id)->exec();
// Clean up the container by first deleting it and then removing the image
auto deletecontainer = dockerclient.removeContainerCmd(response.id)->exec();
auto deleteimage = dockerclient.removeImageCmd("busybox")->exec();
```