summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 1fe8698dc28f3b5840a33f62d5475962acbfdd81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# shiplift

[![Build Status](https://travis-ci.org/softprops/shiplift.svg)](https://travis-ci.org/softprops/shiplift)

> a rust interface for maneuvering docker containers

## docs

Find them [here](https://softprops.github.io/shiplift)

## usage

### communicating with hosts

To use shiplift you must first have a running docker daemon readily accessible. Typically this daemon
is reachable via url identified by an env named `DOCKER_HOST`. If you are using osx, [docker-machine](https://docs.docker.com/machine/) typically
will have already set up every thing you need to get started when you run `docker-machine env {envid}`.

```rust
extern crate shiplift;
let docker = shiplift::Docker::new();
```

If you wish to be more explicit you can provide a host in the form of a `url.Url`.

```rust
extern crate shiplift;
extern crate url;

use shiplift::Docker;
use url::Url;

let docker = Docker::host(Url::parse("http://yourhost").unwrap());
```

### images

If you are interacting with docker containers, chances are you will also need to interact with docker image information. You can interact docker images with `docker.images()`.

```rust
extern crate shiplift;

use shiplift::Docker;

let docker = Docker.new();
let images = docker.images();
```

#### list host-local images

```rust
for i in images.list().unwrap() {
  println!("-> {:?}", i);
}
```

#### find remote images

```rust
for i in image.search("rust").unwrap() {
  println!("- {:?}", i);
}
```

#### creating new images from existing image

todo

#### accessing image info

```rust
let img = images.get("imagename");
```

##### inspecting image info

```rust
println!("- {:?}", img.inspect().unwrap());
```

##### getting image history

```rust
for h in img.history().unwrap() {
  println!("- {:?}", h);
}
```

###### deleting image

```rust
println!("- {:?}", img.delete().unwrap());
```

### containers

Containers are instances of images. To gain access to this interface use `docker.containers()`

```rust
extern crate shiplift;

use shiplift::Docker;

let docker = Docker.new();
let containers = docker.containers();
```

#### listing host local containers

```rust
for c in contains.list().unwrap() {
  println!("- {:?}", c);
}
```

#### get a container reference

```rust
let container = containers.get("containerid");
```

#### inspect container details

```rust
println!("- {:?}", container.inspect());
```

#### access `top` info

```rust
println!("- {:?}", container.top().unwrap());
```

#### view container logs

(todoc)

#### view a list of container changes

```rust
for c in container.changes().unwrap() {
  println!("- {:?}", c);
}
```

#### stream container stats

```rust
for stats in container.stats().unwrap() {
  println!("- {:?}", stats);
}
```

### stop, start, restart container

```rust
container.stop();
container.start();
container.restart();
```

### misc

todoc

Doug Tangren (softprops) 2015