Skip to content

Commit ab5d61d

Browse files
committed
* Added Image.puller() for pulling images.
* Converted Image.pusher() from static to member method. * Renamed ImageBuilder.dockerFile() to dockerfile(). * Added Container for creating and running containers. * Automatically exclude files from the build context based on the contents of Dockerfile and .dockerignore files. * Image.getById() and Image.tag() now throw ImageNotFoundException instead of FileNotFoundException when an image is not found. * Replaced Image.getByDigest() with Image.getByPredicate(). * ImagePusher no longer sends platform if it's not set. * Bugfixes * Image.getById(), ImagePusher.push() now handle image names that contain a slash (e.g. alpine/helm). * Looking up images was always failing because the code was looking for JSON property "id" instead of "Id".
1 parent 004cedb commit ab5d61d

32 files changed

+3529
-1135
lines changed

LICENSE-3RD-PARTY.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
* [Core :: Utilities](https://jetty.org/jetty-core/jetty-util)
2424
* BSD 3-clause:
2525
* [ThreeTen-Extra](https://www.threeten.org/threeten-extra)
26-
* Bouncy Castle Licence:
27-
* [Bouncy Castle PKIX, CMS, EAC, TSP, PKCS, OCSP, CMP, and CRMF APIs](https://www.bouncycastle.org/java.html)
28-
* [Bouncy Castle Provider](https://www.bouncycastle.org/java.html)
29-
* [Bouncy Castle ASN.1 Extension and Utility APIs](https://www.bouncycastle.org/java.html)
3026
* Eclipse Public License - Version 2.0:
3127
* [Core :: ALPN :: Client](https://jetty.org/jetty-core/jetty-alpn/jetty-alpn-client)
3228
* [Core :: HTTP Client](https://jetty.org/jetty-core/jetty-client)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Example
4141
assert (image2.equals(image));
4242

4343
image.tag("rocket-ship", "local-tag");
44-
Image.pusher(client, "rocket-ship", "remote-tag").
44+
image.pusher(client, "rocket-ship", "remote-tag").
4545
credentials("username", "Pa33word").
4646
push();
4747
}

docs/changelog.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ Minor updates involving cosmetic changes have been omitted from this list.
22

33
See https://github.com/cowwoc/docker/commits/main for a full list.
44

5+
## Version 0.5 - 2025/01/16
6+
7+
* Added `Image.puller()` for pulling images.
8+
* Converted `Image.pusher()` from static to member method.
9+
* Renamed `ImageBuilder.dockerFile()` to `dockerfile()`.
10+
* Added `Container` for creating and running containers.
11+
* Automatically exclude files from the build context based on the contents of `Dockerfile` and `.dockerignore`
12+
files.
13+
* `Image.getById()` and `Image.tag()` now throw `ImageNotFoundException` instead of `FileNotFoundException`
14+
when an image is not found.
15+
* Replaced `Image.getByDigest()` with `Image.getByPredicate()`.
16+
* `ImagePusher` no longer sends `platform` if it's not set.
17+
* Bugfixes
18+
* `Image.getById()`, `ImagePusher.push()` now handle image names that contain a slash (e.g. `alpine/helm`).
19+
* Looking up images was always failing because the code was looking for JSON property `id` instead of `Id`.
20+
521
## Version 0.4 - 2025/01/01
622

723
* Bugfixes

pom.xml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<groupId>com.github.cowwoc.docker</groupId>
56
<artifactId>docker</artifactId>
@@ -52,7 +53,7 @@
5253
<pmd.version>7.9.0</pmd.version>
5354
<maven.checkstyle.version>3.6.0</maven.checkstyle.version>
5455
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
55-
<requirements.version>10.5</requirements.version>
56+
<requirements.version>10.9</requirements.version>
5657
</properties>
5758

5859
<dependencies>
@@ -64,7 +65,7 @@
6465
<dependency>
6566
<groupId>ch.qos.logback</groupId>
6667
<artifactId>logback-classic</artifactId>
67-
<version>1.5.15</version>
68+
<version>1.5.16</version>
6869
</dependency>
6970
<dependency>
7071
<groupId>org.eclipse.jetty</groupId>
@@ -96,11 +97,6 @@
9697
<artifactId>sshd-osgi</artifactId>
9798
<version>2.14.0</version>
9899
</dependency>
99-
<dependency>
100-
<groupId>org.bouncycastle</groupId>
101-
<artifactId>bcpkix-jdk18on</artifactId>
102-
<version>1.79</version>
103-
</dependency>
104100
<dependency>
105101
<groupId>org.threeten</groupId>
106102
<artifactId>threeten-extra</artifactId>

src/main/java/com/github/cowwoc/docker/client/DockerClient.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
public interface DockerClient extends AutoCloseable, InternalClient
1717
{
1818
/**
19-
* Creates a client that communicates over a Unix socket.
19+
* Creates a client that communicates with the server over a Unix socket.
2020
*
21-
* @param path the path of the unix path (e.g. {@code /var/run/docker.sock})
21+
* @param path the unix socket of the REST server (e.g. {@code /var/run/docker.sock})
2222
* @return a new client
2323
* @throws NullPointerException if {@code path} is null
2424
*/
@@ -29,9 +29,9 @@ static DockerClient usingUnixSocket(Path path)
2929
}
3030

3131
/**
32-
* Creates a client that communicates over TCP/IP.
32+
* Creates a client that communicates with the server over TCP/IP.
3333
*
34-
* @param uri the URI of the REST API server (e.g. {@code http://localhost:2375/})
34+
* @param uri the URI of the REST server (e.g. {@code http://localhost:2375/})
3535
* @return a new client
3636
* @throws NullPointerException if {@code uri} is null
3737
*/
@@ -41,9 +41,9 @@ static DockerClient usingTcpIp(URI uri)
4141
}
4242

4343
/**
44-
* Determines if the client was closed.
44+
* Determines if the client is closed.
4545
*
46-
* @return {@code true} if the client was closed
46+
* @return {@code true} if the client is closed
4747
*/
4848
boolean isClosed();
4949

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.github.cowwoc.docker.exception;
2+
3+
import com.github.cowwoc.docker.resource.Container;
4+
5+
import java.io.Serial;
6+
7+
import static com.github.cowwoc.requirements10.java.DefaultJavaValidators.requireThat;
8+
9+
/**
10+
* Thrown if the user attempts to start a container that is already started.
11+
*/
12+
public class ContainerAlreadyStartedException extends Exception
13+
{
14+
@Serial
15+
private static final long serialVersionUID = 0L;
16+
private transient final Container container;
17+
18+
/**
19+
* Creates a new instance.
20+
*
21+
* @param container the container
22+
* @throws NullPointerException if {@code container} is null
23+
*/
24+
public ContainerAlreadyStartedException(Container container)
25+
{
26+
super(getMessage(container));
27+
this.container = container;
28+
}
29+
30+
private static String getMessage(Container container)
31+
{
32+
requireThat(container, "container").isNotNull();
33+
return container.getName() + " (" + container.getId() + ") already started";
34+
}
35+
36+
/**
37+
* Returns the container.
38+
*
39+
* @return the container
40+
*/
41+
public Container getContainer()
42+
{
43+
return container;
44+
}
45+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.github.cowwoc.docker.exception;
2+
3+
import java.io.IOException;
4+
import java.io.Serial;
5+
6+
/**
7+
* Thrown if a referenced container does not exist.
8+
*/
9+
public class ContainerNotFoundException extends IOException
10+
{
11+
@Serial
12+
private static final long serialVersionUID = 0L;
13+
14+
/**
15+
* Creates a new instance.
16+
*
17+
* @param message an explanation of what went wrong
18+
*/
19+
public ContainerNotFoundException(String message)
20+
{
21+
super(message);
22+
}
23+
24+
/**
25+
* Creates a new instance.
26+
*
27+
* @param cause the underlying exception
28+
* @throws NullPointerException if {@code cause} is null
29+
*/
30+
public ContainerNotFoundException(Throwable cause)
31+
{
32+
super(cause);
33+
}
34+
}

src/main/java/com/github/cowwoc/docker/exception/ImageNotFoundException.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.github.cowwoc.docker.exception;
22

3+
import java.io.IOException;
34
import java.io.Serial;
45

56
/**
67
* Thrown if a referenced image does not exist.
78
*/
8-
public class ImageNotFoundException extends Exception
9+
public class ImageNotFoundException extends IOException
910
{
1011
@Serial
1112
private static final long serialVersionUID = 0L;
@@ -19,4 +20,14 @@ public ImageNotFoundException(String message)
1920
{
2021
super(message);
2122
}
23+
24+
/**
25+
* Creates a new instance.
26+
*
27+
* @param cause the underlying exception
28+
*/
29+
public ImageNotFoundException(Throwable cause)
30+
{
31+
super(cause);
32+
}
2233
}

0 commit comments

Comments
 (0)