diff --git a/.ci/get-docker-com.sh b/.ci/get-docker-com.sh deleted file mode 100755 index d9c0142a2..000000000 --- a/.ci/get-docker-com.sh +++ /dev/null @@ -1,313 +0,0 @@ -#!/bin/sh -set -e -# -# This script is meant for quick & easy install via: -# 'curl -sSL https://get.docker.com/ | sh' -# or: -# 'wget -qO- https://get.docker.com/ | sh' -# -# For test builds (ie. release candidates): -# 'curl -fsSL https://test.docker.com/ | sh' -# or: -# 'wget -qO- https://test.docker.com/ | sh' -# -# For experimental builds: -# 'curl -fsSL https://experimental.docker.com/ | sh' -# or: -# 'wget -qO- https://experimental.docker.com/ | sh' -# -# Docker Maintainers: -# To update this script on https://get.docker.com, -# use hack/release.sh during a normal release, -# or the following one-liner for script hotfixes: -# aws s3 cp --acl public-read hack/install.sh s3://get.docker.com/index -# - -url="https://get.docker.com/" -apt_url="https://apt.dockerproject.org" -yum_url="https://yum.dockerproject.org" -gpg_fingerprint="58118E89F3A912897C070ADBF76221572C52609D" - -key_servers=" -ha.pool.sks-keyservers.net -pgp.mit.edu -keyserver.ubuntu.com -" - -command_exists() { - command -v "$@" > /dev/null 2>&1 -} - -semverParse() { - major="${1%%.*}" - minor="${1#$major.}" - minor="${minor%%.*}" - patch="${1#$major.$minor.}" - patch="${patch%%[-.]*}" -} - -do_install() { - case "$(uname -m)" in - *64) - ;; - *) - cat >&2 <<-'EOF' - Error: you are not using a 64bit platform. - Docker currently only supports 64bit platforms. - EOF - exit 1 - ;; - esac - - user="$(id -un 2>/dev/null || true)" - - sh_c='sh -c' - if [ "$user" != 'root' ]; then - if command_exists sudo; then - sh_c='sudo -E sh -c' - elif command_exists su; then - sh_c='su -c' - else - cat >&2 <<-'EOF' - Error: this installer needs the ability to run commands as root. - We are unable to find either "sudo" or "su" available to make this happen. - EOF - exit 1 - fi - fi - - curl='' - if command_exists curl; then - curl='curl -sSL' - elif command_exists wget; then - curl='wget -qO-' - elif command_exists busybox && busybox --list-modules | grep -q wget; then - curl='busybox wget -qO-' - fi - - # check to see which repo they are trying to install from - if [ -z "$repo" ]; then - repo='main' - if [ "https://test.docker.com/" = "$url" ]; then - repo='testing' - elif [ "https://experimental.docker.com/" = "$url" ]; then - repo='experimental' - fi - fi - - # perform some very rudimentary platform detection - lsb_dist='' - dist_version='' - if command_exists lsb_release; then - lsb_dist="$(lsb_release -si)" - fi - if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then - lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")" - fi - if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then - lsb_dist='debian' - fi - if [ -z "$lsb_dist" ] && [ -r /etc/fedora-release ]; then - lsb_dist='fedora' - fi - if [ -z "$lsb_dist" ] && [ -r /etc/oracle-release ]; then - lsb_dist='oracleserver' - fi - if [ -z "$lsb_dist" ]; then - if [ -r /etc/centos-release ] || [ -r /etc/redhat-release ]; then - lsb_dist='centos' - fi - fi - if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then - lsb_dist="$(. /etc/os-release && echo "$ID")" - fi - - lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')" - - case "$lsb_dist" in - - ubuntu) - if command_exists lsb_release; then - dist_version="$(lsb_release --codename | cut -f2)" - fi - if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then - dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")" - fi - ;; - - debian) - dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')" - case "$dist_version" in - 8) - dist_version="jessie" - ;; - 7) - dist_version="wheezy" - ;; - esac - ;; - - oracleserver) - # need to switch lsb_dist to match yum repo URL - lsb_dist="oraclelinux" - dist_version="$(rpm -q --whatprovides redhat-release --queryformat "%{VERSION}\n" | sed 's/\/.*//' | sed 's/\..*//' | sed 's/Server*//')" - ;; - - fedora|centos) - dist_version="$(rpm -q --whatprovides redhat-release --queryformat "%{VERSION}\n" | sed 's/\/.*//' | sed 's/\..*//' | sed 's/Server*//')" - ;; - - *) - if command_exists lsb_release; then - dist_version="$(lsb_release --codename | cut -f2)" - fi - if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then - dist_version="$(. /etc/os-release && echo "$VERSION_ID")" - fi - ;; - - - esac - - - # Run setup for each distro accordingly - case "$lsb_dist" in - ubuntu|debian) - export DEBIAN_FRONTEND=noninteractive - - did_apt_get_update= - apt_get_update() { - if [ -z "$did_apt_get_update" ]; then - ( set -x; $sh_c 'sleep 3; apt-get update' ) - did_apt_get_update=1 - fi - } - - # aufs is preferred over devicemapper; try to ensure the driver is available. - if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then - if uname -r | grep -q -- '-generic' && dpkg -l 'linux-image-*-generic' | grep -qE '^ii|^hi' 2>/dev/null; then - kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual" - - apt_get_update - ( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true - - if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then - echo >&2 'Warning: tried to install '"$kern_extras"' (for AUFS)' - echo >&2 ' but we still have no AUFS. Docker may not work. Proceeding anyways!' - ( set -x; sleep 10 ) - fi - else - echo >&2 'Warning: current kernel is not supported by the linux-image-extra-virtual' - echo >&2 ' package. We have no AUFS support. Consider installing the packages' - echo >&2 ' linux-image-virtual kernel and linux-image-extra-virtual for AUFS support.' - ( set -x; sleep 10 ) - fi - fi - - # install apparmor utils if they're missing and apparmor is enabled in the kernel - # otherwise Docker will fail to start - if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then - if command -v apparmor_parser >/dev/null 2>&1; then - echo 'apparmor is enabled in the kernel and apparmor utils were already installed' - else - echo 'apparmor is enabled in the kernel, but apparmor_parser missing' - apt_get_update - ( set -x; $sh_c 'sleep 3; apt-get install -y -q apparmor' ) - fi - fi - - if [ ! -e /usr/lib/apt/methods/https ]; then - apt_get_update - ( set -x; $sh_c 'sleep 3; apt-get install -y -q apt-transport-https ca-certificates' ) - fi - if [ -z "$curl" ]; then - apt_get_update - ( set -x; $sh_c 'sleep 3; apt-get install -y -q curl ca-certificates' ) - curl='curl -sSL' - fi - ( - set -x - for key_server in $key_servers ; do - $sh_c "apt-key adv --keyserver hkp://${key_server}:80 --recv-keys ${gpg_fingerprint}" && break - done - $sh_c "apt-key adv -k ${gpg_fingerprint} >/dev/null" - $sh_c "mkdir -p /etc/apt/sources.list.d" - $sh_c "echo deb [arch=$(dpkg --print-architecture)] ${apt_url}/repo ${lsb_dist}-${dist_version} ${repo} > /etc/apt/sources.list.d/docker.list" - $sh_c 'sleep 3; apt-get update' - if [ -z "$DOCKER_VERSION" ]; then - $sh_c 'apt-get -o Dpkg::Options::="--force-confnew" install -y -q docker-engine' - else - $sh_c "apt-get -o Dpkg::Options::=\"--force-confnew\" install -y -q docker-engine=$DOCKER_VERSION" - fi - ) - exit 0 - ;; - - fedora|centos|oraclelinux) - $sh_c "cat >/etc/yum.repos.d/docker-${repo}.repo" <<-EOF - [docker-${repo}-repo] - name=Docker ${repo} Repository - baseurl=${yum_url}/repo/${repo}/${lsb_dist}/${dist_version} - enabled=1 - gpgcheck=1 - gpgkey=${yum_url}/gpg - EOF - if [ "$lsb_dist" = "fedora" ] && [ "$dist_version" -ge "22" ]; then - ( - set -x - $sh_c 'sleep 3; dnf -y -q install docker-engine' - ) - else - ( - set -x - $sh_c 'sleep 3; yum -y -q install docker-engine' - ) - fi - exit 0 - ;; - gentoo) - if [ "$url" = "https://test.docker.com/" ]; then - # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-'EOF'", spaces are kept in the output - cat >&2 <<-'EOF' - - You appear to be trying to install the latest nightly build in Gentoo.' - The portage tree should contain the latest stable release of Docker, but' - if you want something more recent, you can always use the live ebuild' - provided in the "docker" overlay available via layman. For more' - instructions, please see the following URL:' - - https://github.com/tianon/docker-overlay#using-this-overlay' - - After adding the "docker" overlay, you should be able to:' - - emerge -av =app-emulation/docker-9999' - - EOF - exit 1 - fi - - ( - set -x - $sh_c 'sleep 3; emerge app-emulation/docker' - ) - exit 0 - ;; - esac - - # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-'EOF'", spaces are kept in the output - cat >&2 <<-'EOF' - - Either your platform is not easily detectable, is not supported by this - installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have - a package for Docker. Please visit the following URL for more detailed - installation instructions: - - https://docs.docker.com/engine/installation/ - - EOF - exit 1 -} - -# wrapped up in a function so that we have some protection against only getting -# half the file during "curl | sh" -do_install diff --git a/.ci/setup_docker.sh b/.ci/setup_docker.sh deleted file mode 100755 index df9cf205a..000000000 --- a/.ci/setup_docker.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -set -exu - -DOCKER_VERSION="${DOCKER_VERSION:-}" -DOCKER_HOST="${DOCKER_HOST:-}" - -if [[ -n $DOCKER_VERSION ]]; then - sudo -E apt-get -q -y --purge remove docker-engine docker-ce - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo apt-get update - sudo apt-cache madison docker-ce - sudo apt-get install "docker-ce=$DOCKER_VERSION" -fi - -if [[ -n $DOCKER_HOST ]]; then - sudo mkdir -p /etc/systemd/system/docker.service.d/ - - echo " -[Service] -ExecStart= -ExecStart=/usr/bin/dockerd -H $DOCKER_HOST -H unix:///var/run/docker.sock - " | sudo tee -a /etc/systemd/system/docker.service.d/override.conf - - sudo systemctl daemon-reload - sudo service docker restart || sudo journalctl -xe - sudo service docker status -fi - -while (! docker ps ); do - echo "Waiting for Docker to launch..." - sleep 1 -done -docker version -docker info - -docker run --rm hello-world diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7dec19aef..d301147be 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,5 +4,6 @@ updates: directory: "/" schedule: interval: weekly + day: tuesday open-pull-requests-limit: 99 rebase-strategy: disabled diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f1ef43de..5d6f8d370 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,34 +3,51 @@ name: CI on: pull_request: {} push: { branches: [ main ] } + workflow_dispatch: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: include: - { name: "default", javaVersion: 8 } - { name: "default", javaVersion: 17 } - - { name: "over TCP", dockerHost: "tcp://127.0.0.1:2375", javaVersion: 8 } - - { name: "Docker 19.03.9", dockerVersion: "5:19.03.9~3-0~ubuntu-focal", javaVersion: 8 } - + - { name: "default", javaVersion: 21 } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{matrix.javaVersion}} distribution: temurin - name: Configure Docker + id: setup_docker + uses: docker/setup-docker-action@v4 + with: + channel: stable + - name: Build with Maven env: - DOCKER_VERSION: ${{matrix.dockerVersion}} - DOCKER_HOST: ${{matrix.dockerHost}} - run: .ci/setup_docker.sh + DOCKER_HOST: ${{steps.setup_docker.outputs.sock}} + run: ./mvnw --no-transfer-progress verify + + tcp: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 8 + distribution: temurin + - name: Configure Docker + id: setup_docker + uses: docker/setup-docker-action@v4 + with: + channel: stable + tcp-port: 2375 - name: Build with Maven env: - DOCKER_HOST: ${{matrix.dockerHost}} - run: | - [[ -z "$DOCKER_HOST" ]] && unset DOCKER_HOST - ./mvnw --no-transfer-progress verify + DOCKER_HOST: ${{steps.setup_docker.outputs.tcp}} + run: ./mvnw --no-transfer-progress verify diff --git a/.github/workflows/main.yml b/.github/workflows/release-drafter.yml similarity index 100% rename from .github/workflows/main.yml rename to .github/workflows/release-drafter.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ee128801..3e9f64348 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,18 +8,23 @@ on: jobs: build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 8 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: 8 distribution: temurin + server-id: default + server-username: MAVEN_USERNAME + server-password: MAVEN_CENTRAL_TOKEN - name: Set version run: ./mvnw versions:set -DnewVersion="${{github.event.release.tag_name}}" # TODO check main's CI status - name: Deploy with Maven env: MAVEN_DEPLOYMENT_REPOSITORY: ${{ secrets.MAVEN_DEPLOYMENT_REPOSITORY }} + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }} run: ./mvnw deploy -DaltReleaseDeploymentRepository="$MAVEN_DEPLOYMENT_REPOSITORY" -DskipTests diff --git a/docker-java-api/pom.xml b/docker-java-api/pom.xml index da19bba47..d801546c0 100644 --- a/docker-java-api/pom.xml +++ b/docker-java-api/pom.xml @@ -42,7 +42,7 @@ org.projectlombok lombok - 1.18.22 + 1.18.38 provided @@ -50,14 +50,14 @@ org.junit.jupiter junit-jupiter - 5.10.0 + 5.12.2 test com.tngtech.archunit archunit-junit5 - 0.18.0 + 1.4.1 test @@ -84,6 +84,18 @@ com.github.siom79.japicmp japicmp-maven-plugin + + + + com.github.dockerjava.api.command.UpdateContainerCmd#getCpuPeriod() + com.github.dockerjava.api.command.UpdateContainerCmd#withCpuPeriod(java.lang.Integer) + com.github.dockerjava.api.command.UpdateContainerCmd#getCpuQuota() + com.github.dockerjava.api.command.UpdateContainerCmd#withCpuQuota(java.lang.Integer) + com.github.dockerjava.api.command.InspectContainerResponse#getSizeRootFs() + com.github.dockerjava.api.command.InspectContainerResponse#getSizeRw() + + + diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/command/BuildImageResultCallback.java b/docker-java-api/src/main/java/com/github/dockerjava/api/command/BuildImageResultCallback.java index 331f69509..9db21a6c4 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/command/BuildImageResultCallback.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/command/BuildImageResultCallback.java @@ -67,14 +67,14 @@ public String awaitImageId(long timeout, TimeUnit timeUnit) { } private String getImageId() { - if (imageId != null) { - return imageId; + if (error != null) { + throw new DockerClientException("Could not build image: " + error); } - if (error == null) { - throw new DockerClientException("Could not build image"); + if (imageId != null) { + return imageId; } - throw new DockerClientException("Could not build image: " + error); + throw new DockerClientException("Could not build image"); } } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java b/docker-java-api/src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java index 94207fd2c..f06bd4ed9 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java @@ -61,10 +61,10 @@ public class InspectContainerResponse extends DockerObject { private String id; @JsonProperty("SizeRootFs") - private Integer sizeRootFs; + private Long sizeRootFs; @JsonProperty("SizeRw") - private Integer sizeRw; + private Long sizeRw; @JsonProperty("Image") private String imageId; @@ -124,11 +124,11 @@ public String getId() { return id; } - public Integer getSizeRootFs() { + public Long getSizeRootFs() { return sizeRootFs; } - public Integer getSizeRw() { + public Long getSizeRw() { return sizeRw; } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/command/UpdateContainerCmd.java b/docker-java-api/src/main/java/com/github/dockerjava/api/command/UpdateContainerCmd.java index 82fbca5f8..d53bcdcdf 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/command/UpdateContainerCmd.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/command/UpdateContainerCmd.java @@ -1,9 +1,16 @@ package com.github.dockerjava.api.command; +import com.github.dockerjava.api.model.BlkioRateDevice; +import com.github.dockerjava.api.model.BlkioWeightDevice; +import com.github.dockerjava.api.model.Device; +import com.github.dockerjava.api.model.DeviceRequest; +import com.github.dockerjava.api.model.RestartPolicy; +import com.github.dockerjava.api.model.Ulimit; import com.github.dockerjava.api.model.UpdateContainerResponse; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; +import java.util.List; /** * @author Kanstantsin Shautsou @@ -13,22 +20,47 @@ public interface UpdateContainerCmd extends SyncDockerCmd getBlkioWeightDevice(); + + UpdateContainerCmd withBlkioWeightDevice(List blkioWeightDevice); @CheckForNull - Integer getCpuPeriod(); + List getBlkioDeviceReadBps(); - UpdateContainerCmd withCpuPeriod(Integer cpuPeriod); + UpdateContainerCmd withBlkioDeviceReadBps(List blkioDeviceReadBps); @CheckForNull - Integer getCpuQuota(); + List getBlkioDeviceWriteBps(); - UpdateContainerCmd withCpuQuota(Integer cpuQuota); + UpdateContainerCmd withBlkioDeviceWriteBps(List blkioDeviceWriteBps); + + @CheckForNull + List getBlkioDeviceReadIOps(); + + UpdateContainerCmd withBlkioDeviceReadIOps(List blkioDeviceReadIOps); + + @CheckForNull + List getBlkioDeviceWriteIOps(); + + UpdateContainerCmd withBlkioDeviceWriteIOps(List blkioDeviceWriteIOps); + + @CheckForNull + Long getCpuPeriod(); + + UpdateContainerCmd withCpuPeriod(Long cpuPeriod); + + @CheckForNull + Long getCpuQuota(); + + UpdateContainerCmd withCpuQuota(Long cpuQuota); @CheckForNull String getCpusetCpus(); @@ -45,6 +77,31 @@ public interface UpdateContainerCmd extends SyncDockerCmd getDevices(); + + UpdateContainerCmd withDevices(List devices); + + @CheckForNull + List getDeviceCgroupRules(); + + UpdateContainerCmd withDeviceCgroupRules(List deviceCgroupRules); + + @CheckForNull + List getDeviceRequests(); + + UpdateContainerCmd withDeviceRequests(List deviceRequests); + @CheckForNull Long getKernelMemory(); @@ -65,6 +122,36 @@ public interface UpdateContainerCmd extends SyncDockerCmd getUlimits(); + + UpdateContainerCmd withUlimits(List ulimits); + + @CheckForNull + RestartPolicy getRestartPolicy(); + + UpdateContainerCmd withRestartPolicy(RestartPolicy restartPolicy); + interface Exec extends DockerCmdSyncExec { } } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Capability.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Capability.java index fe71864c0..57fb97c7b 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Capability.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Capability.java @@ -1,5 +1,7 @@ package com.github.dockerjava.api.model; +import com.fasterxml.jackson.annotation.JsonCreator; + /** * The Linux capabilities supported by Docker. The list of capabilities is defined in Docker's types.go, {@link #ALL} was added manually. * @@ -299,5 +301,11 @@ public enum Capability { /** * Trigger something that will wake up the system (set CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM timers). */ - WAKE_ALARM + WAKE_ALARM; + + @JsonCreator + public static Capability fromValue(String cap) { + String result = !cap.startsWith("CAP_") ? cap : cap.split("_", 2)[1]; + return Capability.valueOf(result); + } } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/ImageOptions.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/ImageOptions.java new file mode 100644 index 000000000..bc8b89acb --- /dev/null +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/ImageOptions.java @@ -0,0 +1,27 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.io.Serializable; + +/** + * @since {@link RemoteApiVersion#VERSION_1_48} + */ +@EqualsAndHashCode +@ToString +public class ImageOptions extends DockerObject implements Serializable { + private static final long serialVersionUID = 1L; + @JsonProperty("Subpath") + private String subpath; + + public String getSubpath() { + return subpath; + } + + public ImageOptions withSubpath(String subpath) { + this.subpath = subpath; + return this; + } +} diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Info.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Info.java index 0752778e3..67348b86b 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Info.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Info.java @@ -97,6 +97,12 @@ public class Info extends DockerObject implements Serializable { @JsonProperty("LoggingDriver") private String loggingDriver; + @JsonProperty("CgroupDriver") + private String cGroupDriver; + + @JsonProperty("CgroupVersion") + private String cGroupVersion; + /** * @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_20} */ @@ -235,6 +241,9 @@ public class Info extends DockerObject implements Serializable { @JsonProperty("SecurityOptions") private List securityOptions; + @JsonProperty("Runtimes") + private Map runtimes; + /** * @see #architecture */ @@ -483,6 +492,22 @@ public String getLoggingDriver() { return loggingDriver; } + /** + * @see #cGroupDriver + */ + @CheckForNull + public String getCGroupDriver() { + return cGroupDriver; + } + + /** + * @see #cGroupVersion + */ + @CheckForNull + public String getCGroupVersion() { + return cGroupVersion; + } + /** * @see #loggingDriver */ @@ -491,6 +516,22 @@ public Info withLoggingDriver(String loggingDriver) { return this; } + /** + * @see #cGroupDriver + */ + public Info withCGroupDriver(String cGroupDriver) { + this.cGroupDriver = cGroupDriver; + return this; + } + + /** + * @see #cGroupVersion + */ + public Info withCGroupVersion(String cGroupVersion) { + this.cGroupVersion = cGroupVersion; + return this; + } + /** * @see #experimentalBuild */ @@ -1067,7 +1108,33 @@ public Info withIsolation(String isolation) { return this; } + /** + * @see #securityOptions + */ public List getSecurityOptions() { return securityOptions; } + + /** + * @see #securityOptions + */ + public Info withSecurityOptions(List securityOptions) { + this.securityOptions = securityOptions; + return this; + } + + /** + * @see #runtimes + */ + public Map getRuntimes() { + return runtimes; + } + + /** + * @see #runtimes + */ + public Info withRuntimes(Map runtimes) { + this.runtimes = runtimes; + return this; + } } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Mount.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Mount.java index 9bfe9b16e..3f17343c3 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Mount.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Mount.java @@ -57,6 +57,12 @@ public class Mount extends DockerObject implements Serializable { @JsonProperty("TmpfsOptions") private TmpfsOptions tmpfsOptions; + /** + * @since 1.48 + */ + @JsonProperty("ImageOptions") + private ImageOptions imageOptions; + /** * @see #type */ @@ -177,4 +183,23 @@ public Mount withTmpfsOptions(TmpfsOptions tmpfsOptions) { } return this; } + + /** + * @see #imageOptions + */ + @CheckForNull + public ImageOptions getImageOptions() { + return imageOptions; + } + + /** + * @see #imageOptions + */ + public Mount withImageOptions(ImageOptions imageOptions) { + this.imageOptions = imageOptions; + if (imageOptions != null) { + this.type = MountType.IMAGE; + } + return this; + } } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/MountType.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/MountType.java index 219782a56..b522c9612 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/model/MountType.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/MountType.java @@ -18,6 +18,10 @@ public enum MountType { //@since 1.40 @JsonProperty("npipe") - NPIPE + NPIPE, + + //@since 1.48 + @JsonProperty("image") + IMAGE, } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Network.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Network.java index 7e5110ce6..7e9d3b2fd 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Network.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Network.java @@ -7,6 +7,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; @@ -18,6 +19,9 @@ public class Network extends DockerObject implements Serializable { @JsonProperty("Id") private String id; + @JsonProperty("Created") + private Date created; + @JsonProperty("Name") private String name; @@ -52,6 +56,10 @@ public String getId() { return id; } + public Date getCreated() { + return created; + } + public String getName() { return name; } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/PullResponseItem.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/PullResponseItem.java index 66a559934..1d3f33c8e 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/model/PullResponseItem.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/PullResponseItem.java @@ -19,6 +19,8 @@ public class PullResponseItem extends ResponseItem { private static final String DOWNLOADED_SWARM = ": downloaded"; + private static final String ALREADY_EXISTS = "Already exists"; + /** * Returns whether the status indicates a successful pull operation * @@ -34,7 +36,8 @@ public boolean isPullSuccessIndicated() { getStatus().contains(IMAGE_UP_TO_DATE) || getStatus().contains(DOWNLOADED_NEWER_IMAGE) || getStatus().contains(LEGACY_REGISTRY) || - getStatus().contains(DOWNLOADED_SWARM) + getStatus().contains(DOWNLOADED_SWARM) || + getStatus().contains(ALREADY_EXISTS) ); } } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/RuntimeInfo.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/RuntimeInfo.java new file mode 100644 index 000000000..c64511cda --- /dev/null +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/RuntimeInfo.java @@ -0,0 +1,23 @@ +package com.github.dockerjava.api.model; + +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.io.Serializable; + +@EqualsAndHashCode +@ToString +public class RuntimeInfo extends DockerObject implements Serializable { + private static final long serialVersionUID = 1L; + + private String path; + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + +} diff --git a/docker-java-core/pom.xml b/docker-java-core/pom.xml index b8369fa37..290a1fed9 100644 --- a/docker-java-core/pom.xml +++ b/docker-java-core/pom.xml @@ -99,6 +99,7 @@ 8 8 + true diff --git a/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java b/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java index 8011a2a5e..dad75b360 100644 --- a/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java +++ b/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java @@ -5,6 +5,8 @@ import com.github.dockerjava.api.model.AuthConfigurations; import com.github.dockerjava.core.NameParser.HostnameReposName; import com.github.dockerjava.core.NameParser.ReposTag; + +import java.util.Map.Entry; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; @@ -128,9 +130,11 @@ private static Properties loadIncludedDockerProperties(Properties systemProperti } private static void replaceProperties(Properties properties, Properties replacements) { - for (Object objectKey : properties.keySet()) { - String key = objectKey.toString(); - properties.setProperty(key, replaceProperties(properties.getProperty(key), replacements)); + for (Entry entry : properties.entrySet()) { + final String key = entry.getKey().toString(); + // no entry.getValue here because it does not have the same semantics as getProperty (defaults handling) + final String value = properties.getProperty(key); + entry.setValue(replaceProperties(value, replacements)); } } diff --git a/docker-java-core/src/main/java/com/github/dockerjava/core/LocalDirectorySSLConfig.java b/docker-java-core/src/main/java/com/github/dockerjava/core/LocalDirectorySSLConfig.java index 665f48f06..0f50f561d 100644 --- a/docker-java-core/src/main/java/com/github/dockerjava/core/LocalDirectorySSLConfig.java +++ b/docker-java-core/src/main/java/com/github/dockerjava/core/LocalDirectorySSLConfig.java @@ -64,7 +64,8 @@ public SSLContext getSSLContext() { TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(tmfAlgorithm); trustManagerFactory.init(CertificateUtils.createTrustStore(capem)); - SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); + SSLContext sslContext = SSLContext.getInstance(AccessController.doPrivileged(getSystemProperty("ssl.protocol", + "TLSv1.2"))); sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); return sslContext; diff --git a/docker-java-core/src/main/java/com/github/dockerjava/core/command/UpdateContainerCmdImpl.java b/docker-java-core/src/main/java/com/github/dockerjava/core/command/UpdateContainerCmdImpl.java index 14357ba08..47ab710eb 100644 --- a/docker-java-core/src/main/java/com/github/dockerjava/core/command/UpdateContainerCmdImpl.java +++ b/docker-java-core/src/main/java/com/github/dockerjava/core/command/UpdateContainerCmdImpl.java @@ -4,6 +4,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.dockerjava.api.command.UpdateContainerCmd; import com.github.dockerjava.api.exception.NotFoundException; +import com.github.dockerjava.api.model.BlkioRateDevice; +import com.github.dockerjava.api.model.BlkioWeightDevice; +import com.github.dockerjava.api.model.Device; +import com.github.dockerjava.api.model.DeviceRequest; +import com.github.dockerjava.api.model.RestartPolicy; +import com.github.dockerjava.api.model.Ulimit; import com.github.dockerjava.api.model.UpdateContainerResponse; import com.github.dockerjava.core.RemoteApiVersion; import org.apache.commons.lang3.builder.EqualsBuilder; @@ -12,6 +18,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; +import java.util.List; /** * @author Kanstantsin Shautsou @@ -28,14 +35,38 @@ public class UpdateContainerCmdImpl extends AbstrDockerCmd blkioWeightDevice; + + @JsonProperty("BlkioDeviceReadBps") + private List blkioDeviceReadBps; + + @JsonProperty("BlkioDeviceWriteBps") + private List blkioDeviceWriteBps; + + @JsonProperty("BlkioDeviceReadIOps") + private List blkioDeviceReadIOps; + + @JsonProperty("BlkioDeviceWriteIOps") + private List blkioDeviceWriteIOps; + @JsonProperty("CpuShares") private Integer cpuShares; @JsonProperty("CpuPeriod") - private Integer cpuPeriod; + private Long cpuPeriod; @JsonProperty("CpuQuota") - private Integer cpuQuota; + private Long cpuQuota; + + @JsonProperty("CpuRealtimePeriod") + private Long cpuRealtimePeriod; + + @JsonProperty("CpuRealtimeRuntime") + private Long cpuRealtimeRuntime; + + @JsonProperty("NanoCpus") + private Long nanoCPUs; @JsonProperty("CpusetCpus") private String cpusetCpus; @@ -43,6 +74,18 @@ public class UpdateContainerCmdImpl extends AbstrDockerCmd devices; + + @JsonProperty("DeviceCgroupRules") + private List deviceCgroupRules; + + /** + * @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_40} + */ + @JsonProperty("DeviceRequests") + private List deviceRequests; + @JsonProperty("Memory") private Long memory; @@ -55,11 +98,43 @@ public class UpdateContainerCmdImpl extends AbstrDockerCmd ulimits; + + @JsonProperty("RestartPolicy") + private RestartPolicy restartPolicy; + public UpdateContainerCmdImpl(UpdateContainerCmd.Exec exec, String containerId) { super(exec); withContainerId(containerId); } + /** + * @see #containerId + */ + @CheckForNull + @JsonIgnore + public String getContainerId() { + return containerId; + } + + /** + * @see #containerId + */ + public UpdateContainerCmd withContainerId(@Nonnull String containerId) { + this.containerId = containerId; + return this; + } + /** * @see #blkioWeight */ @@ -77,19 +152,68 @@ public UpdateContainerCmd withBlkioWeight(Integer blkioWeight) { } /** - * @see #containerId + * @see #blkioWeightDevice */ @CheckForNull - @JsonIgnore - public String getContainerId() { - return containerId; + public List getBlkioWeightDevice() { + return blkioWeightDevice; + } + + public UpdateContainerCmd withBlkioWeightDevice(List blkioWeightDevice) { + this.blkioWeightDevice = blkioWeightDevice; + return this; } /** - * @see #containerId + * @see #blkioDeviceReadBps */ - public UpdateContainerCmd withContainerId(@Nonnull String containerId) { - this.containerId = containerId; + @CheckForNull + public List getBlkioDeviceReadBps() { + return blkioDeviceReadBps; + } + + public UpdateContainerCmd withBlkioDeviceReadBps(List blkioDeviceReadBps) { + this.blkioDeviceReadBps = blkioDeviceReadBps; + return this; + } + + /** + * @see #blkioDeviceWriteBps + */ + @CheckForNull + public List getBlkioDeviceWriteBps() { + return blkioDeviceWriteBps; + } + + public UpdateContainerCmd withBlkioDeviceWriteBps(List blkioDeviceWriteBps) { + this.blkioDeviceWriteBps = blkioDeviceWriteBps; + return this; + } + + /** + * @see #blkioDeviceReadIOps + */ + @CheckForNull + public List getBlkioDeviceReadIOps() { + return blkioDeviceReadIOps; + } + + public UpdateContainerCmd withBlkioDeviceReadIOps(List blkioDeviceReadIOps) { + this.blkioDeviceReadIOps = blkioDeviceReadIOps; + return this; + } + + /** + * @see #blkioDeviceWriteIOps + */ + @CheckForNull + public List getBlkioDeviceWriteIOps() { + return blkioDeviceWriteIOps; + } + + @Override + public UpdateContainerCmd withBlkioDeviceWriteIOps(List blkioDeviceWriteIOps) { + this.blkioDeviceWriteIOps = blkioDeviceWriteIOps; return this; } @@ -97,14 +221,14 @@ public UpdateContainerCmd withContainerId(@Nonnull String containerId) { * @see #cpuPeriod */ @CheckForNull - public Integer getCpuPeriod() { + public Long getCpuPeriod() { return cpuPeriod; } /** * @see #cpuPeriod */ - public UpdateContainerCmd withCpuPeriod(Integer cpuPeriod) { + public UpdateContainerCmd withCpuPeriod(Long cpuPeriod) { this.cpuPeriod = cpuPeriod; return this; } @@ -113,14 +237,14 @@ public UpdateContainerCmd withCpuPeriod(Integer cpuPeriod) { * @see #cpuQuota */ @CheckForNull - public Integer getCpuQuota() { + public Long getCpuQuota() { return cpuQuota; } /** * @see #cpuQuota */ - public UpdateContainerCmd withCpuQuota(Integer cpuQuota) { + public UpdateContainerCmd withCpuQuota(Long cpuQuota) { this.cpuQuota = cpuQuota; return this; } @@ -173,6 +297,71 @@ public UpdateContainerCmd withCpuShares(Integer cpuShares) { return this; } + /** + * @see #cpuRealtimePeriod + */ + @CheckForNull + public Long getCpuRealtimePeriod() { + return cpuRealtimePeriod; + } + + public UpdateContainerCmd withCpuRealtimePeriod(Long cpuRealtimePeriod) { + this.cpuRealtimePeriod = cpuRealtimePeriod; + return this; + } + + /** + * @see #cpuRealtimeRuntime + */ + @CheckForNull + public Long getCpuRealtimeRuntime() { + return cpuRealtimeRuntime; + } + + public UpdateContainerCmd withCpuRealtimeRuntime(Long cpuRealtimeRuntime) { + this.cpuRealtimeRuntime = cpuRealtimeRuntime; + return this; + } + + /** + * @see #devices + */ + @CheckForNull + public List getDevices() { + return devices; + } + + public UpdateContainerCmd withDevices(List devices) { + this.devices = devices; + return this; + } + + /** + * @see #deviceCgroupRules + */ + @CheckForNull + public List getDeviceCgroupRules() { + return deviceCgroupRules; + } + + public UpdateContainerCmd withDeviceCgroupRules(List deviceCgroupRules) { + this.deviceCgroupRules = deviceCgroupRules; + return this; + } + + /** + * @see #deviceRequests + */ + @CheckForNull + public List getDeviceRequests() { + return deviceRequests; + } + + public UpdateContainerCmd withDeviceRequests(List deviceRequests) { + this.deviceRequests = deviceRequests; + return this; + } + /** * @see #kernelMemory */ @@ -237,6 +426,84 @@ public UpdateContainerCmd withMemorySwap(Long memorySwap) { return this; } + /** + * @see #nanoCPUs + */ + @CheckForNull + public Long getNanoCPUs() { + return nanoCPUs; + } + + public UpdateContainerCmd withNanoCPUs(Long nanoCPUs) { + this.nanoCPUs = nanoCPUs; + return this; + } + + /** + * @see #oomKillDisable + */ + @CheckForNull + public Boolean getOomKillDisable() { + return oomKillDisable; + } + + public UpdateContainerCmd withOomKillDisable(Boolean oomKillDisable) { + this.oomKillDisable = oomKillDisable; + return this; + } + + /** + * @see #init + */ + @CheckForNull + public Boolean getInit() { + return init; + } + + public UpdateContainerCmd withInit(Boolean init) { + this.init = init; + return this; + } + + /** + * @see #pidsLimit + */ + @CheckForNull + public Long getPidsLimit() { + return pidsLimit; + } + + public UpdateContainerCmd withPidsLimit(Long pidsLimit) { + this.pidsLimit = pidsLimit; + return this; + } + + /** + * @see #ulimits + */ + @CheckForNull + public List getUlimits() { + return ulimits; + } + + public UpdateContainerCmd withUlimits(List ulimits) { + this.ulimits = ulimits; + return this; + } + + /** + * @see #restartPolicy + */ + @CheckForNull + public RestartPolicy getRestartPolicy() { + return restartPolicy; + } + + public UpdateContainerCmd withRestartPolicy(RestartPolicy restartPolicy) { + this.restartPolicy = restartPolicy; + return this; + } + /** * @throws NotFoundException No such container */ diff --git a/docker-java-transport-httpclient5/pom.xml b/docker-java-transport-httpclient5/pom.xml index 4eb9f41df..261922992 100644 --- a/docker-java-transport-httpclient5/pom.xml +++ b/docker-java-transport-httpclient5/pom.xml @@ -29,19 +29,13 @@ org.apache.httpcomponents.client5 httpclient5 - 5.0.3 - - - org.apache.httpcomponents.core5 - httpcore5-h2 - - + 5.4.4 net.java.dev.jna jna - 5.13.0 + 5.17.0 diff --git a/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java b/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java index 93677bd36..c97a2bc45 100644 --- a/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java +++ b/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java @@ -4,31 +4,34 @@ import com.github.dockerjava.transport.NamedPipeSocket; import com.github.dockerjava.transport.SSLConfig; import com.github.dockerjava.transport.UnixSocket; + +import org.apache.hc.client5.http.SystemDefaultDnsResolver; import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase; +import org.apache.hc.client5.http.config.ConnectionConfig; import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.DefaultSchemePortResolver; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; -import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator; import org.apache.hc.client5.http.impl.io.ManagedHttpClientConnectionFactory; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; -import org.apache.hc.client5.http.socket.ConnectionSocketFactory; -import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory; -import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.client5.http.io.HttpClientConnectionOperator; +import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy; +import org.apache.hc.client5.http.ssl.TlsSocketStrategy; +import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.ConnectionClosedException; import org.apache.hc.core5.http.ContentLengthStrategy; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.NameValuePair; -import org.apache.hc.core5.http.config.Registry; -import org.apache.hc.core5.http.config.RegistryBuilder; import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy; -import org.apache.hc.core5.http.impl.io.EmptyInputStream; import org.apache.hc.core5.http.io.SocketConfig; import org.apache.hc.core5.http.io.entity.ByteArrayEntity; +import org.apache.hc.core5.http.io.entity.EmptyInputStream; import org.apache.hc.core5.http.io.entity.InputStreamEntity; -import org.apache.hc.core5.http.protocol.BasicHttpContext; import org.apache.hc.core5.http.protocol.HttpContext; +import org.apache.hc.core5.http.protocol.HttpCoreContext; import org.apache.hc.core5.net.URIAuthority; import org.apache.hc.core5.util.TimeValue; import org.apache.hc.core5.util.Timeout; @@ -60,7 +63,13 @@ protected ApacheDockerHttpClientImpl( Duration connectionTimeout, Duration responseTimeout ) { - Registry socketFactoryRegistry = createConnectionSocketFactoryRegistry(sslConfig, dockerHost); + SSLContext sslContext; + try { + sslContext = sslConfig != null ? sslConfig.getSSLContext() : null; + } catch (Exception e) { + throw new RuntimeException(e); + } + HttpClientConnectionOperator connectionOperator = createConnectionOperator(dockerHost, sslContext); switch (dockerHost.getScheme()) { case "unix": @@ -74,7 +83,7 @@ protected ApacheDockerHttpClientImpl( ? rawPath.substring(0, rawPath.length() - 1) : rawPath; host = new HttpHost( - socketFactoryRegistry.lookup("https") != null ? "https" : "http", + sslContext != null ? "https" : "http", dockerHost.getHost(), dockerHost.getPort() ); @@ -84,7 +93,10 @@ protected ApacheDockerHttpClientImpl( } PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager( - socketFactoryRegistry, + connectionOperator, + null, + null, + null, new ManagedHttpClientConnectionFactory( null, null, @@ -108,63 +120,49 @@ protected ApacheDockerHttpClientImpl( .setSoTimeout(Timeout.ZERO_MILLISECONDS) .build() ); - connectionManager.setValidateAfterInactivity(TimeValue.NEG_ONE_SECOND); connectionManager.setMaxTotal(maxConnections); connectionManager.setDefaultMaxPerRoute(maxConnections); - RequestConfig.Builder defaultRequest = RequestConfig.custom(); - if (connectionTimeout != null) { - defaultRequest.setConnectTimeout(connectionTimeout.toNanos(), TimeUnit.NANOSECONDS); - } - if (responseTimeout != null) { - defaultRequest.setResponseTimeout(responseTimeout.toNanos(), TimeUnit.NANOSECONDS); - } + connectionManager.setDefaultConnectionConfig(ConnectionConfig.custom() + .setValidateAfterInactivity(TimeValue.NEG_ONE_SECOND) + .setConnectTimeout(connectionTimeout != null ? Timeout.of(connectionTimeout.toNanos(), TimeUnit.NANOSECONDS) : null) + .build()); httpClient = HttpClients.custom() .setRequestExecutor(new HijackingHttpRequestExecutor(null)) .setConnectionManager(connectionManager) - .setDefaultRequestConfig(defaultRequest.build()) + .setDefaultRequestConfig(RequestConfig.custom() + .setResponseTimeout(responseTimeout != null ? Timeout.of(responseTimeout.toNanos(), TimeUnit.NANOSECONDS) : null) + .build()) .disableConnectionState() .build(); } - private Registry createConnectionSocketFactoryRegistry( - SSLConfig sslConfig, - URI dockerHost + private HttpClientConnectionOperator createConnectionOperator( + URI dockerHost, + SSLContext sslContext ) { - RegistryBuilder socketFactoryRegistryBuilder = RegistryBuilder.create(); - - if (sslConfig != null) { - try { - SSLContext sslContext = sslConfig.getSSLContext(); - if (sslContext != null) { - socketFactoryRegistryBuilder.register("https", new SSLConnectionSocketFactory(sslContext)); + String dockerHostScheme = dockerHost.getScheme(); + String dockerHostPath = dockerHost.getPath(); + TlsSocketStrategy tlsSocketStrategy = sslContext != null ? + new DefaultClientTlsStrategy(sslContext) : DefaultClientTlsStrategy.createSystemDefault(); + return new DefaultHttpClientConnectionOperator( + socksProxy -> { + if ("unix".equalsIgnoreCase(dockerHostScheme)) { + return UnixSocket.get(dockerHostPath); + } else if ("npipe".equalsIgnoreCase(dockerHostScheme)) { + return new NamedPipeSocket(dockerHostPath); + } else { + return socksProxy == null ? new Socket() : new Socket(socksProxy); } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - return socketFactoryRegistryBuilder - .register("tcp", PlainConnectionSocketFactory.INSTANCE) - .register("http", PlainConnectionSocketFactory.INSTANCE) - .register("unix", new PlainConnectionSocketFactory() { - @Override - public Socket createSocket(HttpContext context) throws IOException { - return UnixSocket.get(dockerHost.getPath()); - } - }) - .register("npipe", new PlainConnectionSocketFactory() { - @Override - public Socket createSocket(HttpContext context) { - return new NamedPipeSocket(dockerHost.getPath()); - } - }) - .build(); + }, + DefaultSchemePortResolver.INSTANCE, + SystemDefaultDnsResolver.INSTANCE, + name -> "https".equalsIgnoreCase(name) ? tlsSocketStrategy : null); } @Override public Response execute(Request request) { - HttpContext context = new BasicHttpContext(); + HttpContext context = new HttpCoreContext(); HttpUriRequestBase httpUriRequest = new HttpUriRequestBase(request.method(), URI.create(pathPrefix + request.path())); httpUriRequest.setScheme(host.getSchemeName()); httpUriRequest.setAuthority(new URIAuthority(host.getHostName(), host.getPort())); @@ -188,7 +186,7 @@ public Response execute(Request request) { } try { - CloseableHttpResponse response = httpClient.execute(host, httpUriRequest, context); + ClassicHttpResponse response = httpClient.executeOpen(host, httpUriRequest, context); return new ApacheResponse(httpUriRequest, response); } catch (IOException e) { @@ -207,9 +205,9 @@ static class ApacheResponse implements Response { private final HttpUriRequestBase request; - private final CloseableHttpResponse response; + private final ClassicHttpResponse response; - ApacheResponse(HttpUriRequestBase httpUriRequest, CloseableHttpResponse response) { + ApacheResponse(HttpUriRequestBase httpUriRequest, ClassicHttpResponse response) { this.request = httpUriRequest; this.response = response; } diff --git a/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/HijackingHttpRequestExecutor.java b/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/HijackingHttpRequestExecutor.java index 59888a5dd..df8fbd059 100644 --- a/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/HijackingHttpRequestExecutor.java +++ b/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/HijackingHttpRequestExecutor.java @@ -44,7 +44,7 @@ public ClassicHttpResponse execute( InputStream hijackedInput = (InputStream) context.getAttribute(HIJACKED_INPUT_ATTRIBUTE); if (hijackedInput != null) { - return executeHijacked(request, conn, context, hijackedInput); + return executeHijacked(request, conn, (HttpCoreContext) context, hijackedInput); } return super.execute(request, conn, informationCallback, context); @@ -53,12 +53,12 @@ public ClassicHttpResponse execute( private ClassicHttpResponse executeHijacked( ClassicHttpRequest request, HttpClientConnection conn, - HttpContext context, + HttpCoreContext context, InputStream hijackedInput ) throws HttpException, IOException { try { - context.setAttribute(HttpCoreContext.SSL_SESSION, conn.getSSLSession()); - context.setAttribute(HttpCoreContext.CONNECTION_ENDPOINT, conn.getEndpointDetails()); + context.setSSLSession(conn.getSSLSession()); + context.setEndpointDetails(conn.getEndpointDetails()); final ProtocolVersion transportVersion = request.getVersion(); if (transportVersion != null) { context.setProtocolVersion(transportVersion); diff --git a/docker-java-transport-okhttp/pom.xml b/docker-java-transport-okhttp/pom.xml index df14ad077..3bac0cead 100644 --- a/docker-java-transport-okhttp/pom.xml +++ b/docker-java-transport-okhttp/pom.xml @@ -35,7 +35,7 @@ net.java.dev.jna jna - 5.13.0 + 5.17.0 diff --git a/docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp/UnixSocketFactory.java b/docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp/UnixSocketFactory.java index dc19b1351..d25bcb3d3 100644 --- a/docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp/UnixSocketFactory.java +++ b/docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp/UnixSocketFactory.java @@ -20,7 +20,7 @@ public Socket createSocket() { try { return UnixSocket.get(socketPath); } catch (IOException e) { - throw new RuntimeException(e); + throw new RuntimeException("Failed create socket with path " + socketPath, e); } } diff --git a/docker-java-transport-tck/pom.xml b/docker-java-transport-tck/pom.xml index 2e4bd79ce..73161b458 100644 --- a/docker-java-transport-tck/pom.xml +++ b/docker-java-transport-tck/pom.xml @@ -34,7 +34,7 @@ org.assertj assertj-core - 3.24.2 + 3.27.3 @@ -46,7 +46,7 @@ org.testcontainers testcontainers - 1.19.1 + 1.21.0 diff --git a/docker-java-transport/pom.xml b/docker-java-transport/pom.xml index 2ca377dd6..96f1f850a 100644 --- a/docker-java-transport/pom.xml +++ b/docker-java-transport/pom.xml @@ -30,14 +30,14 @@ org.immutables value - 2.8.2 + 2.10.1 provided net.java.dev.jna jna - 5.13.0 + 5.17.0 provided diff --git a/docker-java-transport/src/main/java/com/github/dockerjava/transport/UnixSocket.java b/docker-java-transport/src/main/java/com/github/dockerjava/transport/UnixSocket.java index de447db61..eb7a49b51 100644 --- a/docker-java-transport/src/main/java/com/github/dockerjava/transport/UnixSocket.java +++ b/docker-java-transport/src/main/java/com/github/dockerjava/transport/UnixSocket.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.lang.reflect.InvocationTargetException; import java.net.Socket; import java.net.SocketAddress; import java.net.SocketException; @@ -24,7 +25,8 @@ public class UnixSocket extends AbstractSocket { public static Socket get(String path) throws IOException { try { return new UnixSocket(path); - } catch (Exception e) { + } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | + IllegalAccessException e) { //noinspection deprecation return DomainSocket.get(path); } @@ -34,7 +36,8 @@ public static Socket get(String path) throws IOException { private final SocketChannel socketChannel; - private UnixSocket(String path) throws Exception { + private UnixSocket(String path) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, + IllegalAccessException, IOException { Class unixDomainSocketAddress = Class.forName("java.net.UnixDomainSocketAddress"); this.socketAddress = (SocketAddress) unixDomainSocketAddress.getMethod("of", String.class) diff --git a/docker-java/pom.xml b/docker-java/pom.xml index 39e1b1b65..e00c974d3 100644 --- a/docker-java/pom.xml +++ b/docker-java/pom.xml @@ -118,30 +118,30 @@ org.awaitility awaitility - 4.0.1 + 4.3.0 test com.fasterxml.jackson.core jackson-databind - - 2.8.8 + + 2.18.3 test com.fasterxml.jackson.core jackson-annotations - - 2.8.8 + + 2.18.3 test org.projectlombok lombok - 1.18.22 + 1.18.38 provided diff --git a/docker-java/src/main/java/com/github/dockerjava/core/DockerClientBuilder.java b/docker-java/src/main/java/com/github/dockerjava/core/DockerClientBuilder.java index a3e4c3909..8100f285e 100644 --- a/docker-java/src/main/java/com/github/dockerjava/core/DockerClientBuilder.java +++ b/docker-java/src/main/java/com/github/dockerjava/core/DockerClientBuilder.java @@ -94,7 +94,7 @@ public DockerClient build() { } else { Logger log = LoggerFactory.getLogger(DockerClientBuilder.class); log.warn( - "'dockerHttpClient' should be set." + + "'dockerHttpClient' should be set. " + "Falling back to Jersey, will be an error in future releases." ); diff --git a/docker-java/src/test/java/com/github/dockerjava/api/command/CommandJSONSamples.java b/docker-java/src/test/java/com/github/dockerjava/api/command/CommandJSONSamples.java index 0cf5141d4..23ef4b7f2 100644 --- a/docker-java/src/test/java/com/github/dockerjava/api/command/CommandJSONSamples.java +++ b/docker-java/src/test/java/com/github/dockerjava/api/command/CommandJSONSamples.java @@ -28,7 +28,9 @@ public enum CommandJSONSamples implements JSONResourceRef { inspectContainerResponse_full_1_21, inspectContainerResponse_full_1_26a, inspectContainerResponse_full_1_26b, - inspectContainerResponse_empty; + inspectContainerResponse_empty, + updateContainerResponse_empty, + updateContainerResponse_warnings; @Override public String getFileName() { diff --git a/docker-java/src/test/java/com/github/dockerjava/api/command/UpdateContainerResponseTest.java b/docker-java/src/test/java/com/github/dockerjava/api/command/UpdateContainerResponseTest.java new file mode 100644 index 000000000..300a5c324 --- /dev/null +++ b/docker-java/src/test/java/com/github/dockerjava/api/command/UpdateContainerResponseTest.java @@ -0,0 +1,33 @@ +package com.github.dockerjava.api.command; + +import com.github.dockerjava.api.model.UpdateContainerResponse; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; + +import static com.github.dockerjava.test.serdes.JSONTestHelper.testRoundTrip; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class UpdateContainerResponseTest { + @Test + public void roundTrip_empty() throws IOException { + UpdateContainerResponse response = testRoundTrip(CommandJSONSamples.updateContainerResponse_empty, UpdateContainerResponse.class); + assertNull(response.getWarnings()); + } + + @Test + public void roundTrip_warnings() throws IOException { + UpdateContainerResponse response = testRoundTrip(CommandJSONSamples.updateContainerResponse_warnings, + UpdateContainerResponse.class); + + List warnings = response.getWarnings(); + assertNotNull(warnings); + assertEquals(1, warnings.size()); + + final String warning = warnings.get(0); + assertEquals("Published ports are discarded when using host network mode", warning); + } +} diff --git a/docker-java/src/test/java/com/github/dockerjava/api/model/CapabilityTest.java b/docker-java/src/test/java/com/github/dockerjava/api/model/CapabilityTest.java index aa6167b8c..b0652d945 100644 --- a/docker-java/src/test/java/com/github/dockerjava/api/model/CapabilityTest.java +++ b/docker-java/src/test/java/com/github/dockerjava/api/model/CapabilityTest.java @@ -18,6 +18,9 @@ public void serializeCapability() throws Exception { public void deserializeCapability() throws Exception { Capability capability = JSONTestHelper.getMapper().readValue("\"ALL\"", Capability.class); assertEquals(Capability.ALL, capability); + + Capability compatibleCapability = JSONTestHelper.getMapper().readValue("\"CAP_ALL\"", Capability.class); + assertEquals(Capability.ALL, compatibleCapability); } @Test(expected = JsonMappingException.class) diff --git a/docker-java/src/test/java/com/github/dockerjava/api/model/PullResponseItemTest.java b/docker-java/src/test/java/com/github/dockerjava/api/model/PullResponseItemTest.java index 486badd55..f73036864 100644 --- a/docker-java/src/test/java/com/github/dockerjava/api/model/PullResponseItemTest.java +++ b/docker-java/src/test/java/com/github/dockerjava/api/model/PullResponseItemTest.java @@ -29,6 +29,14 @@ * @author Zach Marshall */ public class PullResponseItemTest { + @Test + public void imageAlreadyExists() throws IOException { + PullResponseItem response = testRoundTrip(PullResponseJSONSamples.pullImageResponse_alreadyExists, + PullResponseItem.class); + assertTrue(response.isPullSuccessIndicated()); + assertFalse(response.isErrorIndicated()); + } + @Test public void pullNewerImage() throws IOException { PullResponseItem response = testRoundTrip(PullResponseJSONSamples.pullImageResponse_newerImage, diff --git a/docker-java/src/test/java/com/github/dockerjava/api/model/PullResponseJSONSamples.java b/docker-java/src/test/java/com/github/dockerjava/api/model/PullResponseJSONSamples.java index 31cdf0f3b..4997a390a 100644 --- a/docker-java/src/test/java/com/github/dockerjava/api/model/PullResponseJSONSamples.java +++ b/docker-java/src/test/java/com/github/dockerjava/api/model/PullResponseJSONSamples.java @@ -23,7 +23,9 @@ * @author Zach Marshall */ public enum PullResponseJSONSamples implements JSONResourceRef { - pullImageResponse_legacy, pullImageResponse_error, pullImageResponse_newerImage, pullImageResponse_upToDate; + pullImageResponse_legacy, pullImageResponse_error, + pullImageResponse_newerImage, pullImageResponse_upToDate, + pullImageResponse_alreadyExists; @Override public String getFileName() { diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java index de9f564e4..50623c029 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/CreateContainerCmdIT.java @@ -34,7 +34,9 @@ import com.github.dockerjava.utils.TestUtils; import net.jcip.annotations.NotThreadSafe; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.SystemUtils; import org.junit.ClassRule; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -420,6 +422,7 @@ public void createContainerWithLink() throws DockerException { } @Test + @Ignore public void createContainerWithMemorySwappiness() throws DockerException { CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE) .withCmd("sleep", "9999") @@ -959,6 +962,8 @@ public void onNext(Frame item) { @Test public void createContainerWithCgroupParent() throws DockerException { + assumeThat(!SystemUtils.IS_OS_LINUX, is(true)); + CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox") .withHostConfig(newHostConfig() .withCgroupParent("/parent")) diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/CreateNetworkCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/CreateNetworkCmdIT.java index deb8a4718..d60425a2a 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/CreateNetworkCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/CreateNetworkCmdIT.java @@ -15,9 +15,11 @@ import static com.github.dockerjava.junit.DockerMatchers.isGreaterOrEqual; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeThat; @@ -37,6 +39,7 @@ public void createNetwork() throws DockerException { Network network = dockerRule.getClient().inspectNetworkCmd().withNetworkId(createNetworkResponse.getId()).exec(); assertThat(network.getName(), is(networkName)); assertThat(network.getDriver(), is("bridge")); + assertThat(network.getCreated().getTime(), greaterThan(0L)); } @Test diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/InfoCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/InfoCmdIT.java index d7917326b..74fc2cbda 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/InfoCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/InfoCmdIT.java @@ -48,6 +48,7 @@ public void infoTest() throws DockerException { assertThat(dockerInfo.getImages(), notNullValue()); assertThat(dockerInfo.getImages(), greaterThan(0)); assertThat(dockerInfo.getDebug(), notNullValue()); + assertThat(dockerInfo.getRuntimes(), notNullValue()); if (isNotSwarm(dockerClient)) { assertThat(dockerInfo.getNFd(), greaterThan(0)); diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/InspectContainerCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/InspectContainerCmdIT.java index 54d900db8..cc1468f7f 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/InspectContainerCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/InspectContainerCmdIT.java @@ -100,9 +100,9 @@ public void inspectContainerWithSize() throws DockerException { // TODO check swarm if (isNotSwarm(dockerRule.getClient())) { assertNotNull(containerInfo.getSizeRootFs()); - assertTrue(containerInfo.getSizeRootFs().intValue() > 0); + assertTrue(containerInfo.getSizeRootFs() > 0L); assertNotNull(containerInfo.getSizeRw()); - assertTrue(containerInfo.getSizeRw().intValue() == 0); + assertEquals(0L, containerInfo.getSizeRw().longValue()); } } diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/InspectNetworkCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/InspectNetworkCmdIT.java index eca86497d..035d3d767 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/InspectNetworkCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/InspectNetworkCmdIT.java @@ -10,6 +10,7 @@ import static com.github.dockerjava.utils.TestUtils.findNetwork; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; public class InspectNetworkCmdIT extends CmdIT { @@ -28,5 +29,6 @@ public void inspectNetwork() throws DockerException { assertThat(network.getDriver(), equalTo(expected.getDriver())); assertThat(network.getIpam().getConfig().get(0).getSubnet(), equalTo(expected.getIpam().getConfig().get(0).getSubnet())); assertThat(network.getIpam().getDriver(), equalTo(expected.getIpam().getDriver())); + assertThat(network.getCreated().getTime(), greaterThan(0L)); } } diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java index 30667671f..3490924c7 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/ListContainersCmdIT.java @@ -330,11 +330,11 @@ public void testAncestorFilter() throws Exception { DockerAssume.assumeNotSwarm(dockerRule.getClient()); dockerRule.getClient().pullImageCmd("busybox") - .withTag("1.24") + .withTag("1.35") .start() .awaitCompletion(); - dockerRule.getClient().createContainerCmd("busybox:1.24") + dockerRule.getClient().createContainerCmd("busybox:1.35") .withLabels(testLabel) .exec(); diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/PullImageCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/PullImageCmdIT.java index 539a2b606..3b8dde3ff 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/PullImageCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/PullImageCmdIT.java @@ -45,7 +45,7 @@ public void testPullImage() throws Exception { // pulled down, preferably small in size. If tag is not used pull will // download all images in that repository but tmpImgs will only // deleted 'latest' image but not images with other tags - String testImage = "hackmann/empty"; + String testImage = "alpine:3.17"; LOG.info("Removing image: {}", testImage); diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/RestartContainerCmdImplIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/RestartContainerCmdImplIT.java index ac2415281..bdf309dc2 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/RestartContainerCmdImplIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/RestartContainerCmdImplIT.java @@ -60,7 +60,7 @@ public void restartContainerWithSignal() throws Exception { .build(); try (DockerClient dockerClient = createDockerClient(dockerClientConfig)) { String expectedUserSignal = "10"; - String initialCommandWithTrap = "trap 'echo \"exit trapped\"' %s; sleep 9999;"; + String initialCommandWithTrap = "trap 'echo \"exit trapped\"' %s; while :; do sleep 1; done"; final String containerId = dockerClient .createContainerCmd(DEFAULT_IMAGE) .withCmd( diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java index e5bb55499..e1e637809 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java @@ -48,8 +48,8 @@ public void updateContainer() throws DockerException { dockerRule.getClient().updateContainerCmd(containerId) .withBlkioWeight(300) .withCpuShares(512) - .withCpuPeriod(100000) - .withCpuQuota(50000) + .withCpuPeriod(100000L) + .withCpuQuota(50000L) // .withCpusetCpus("0") // depends on env .withCpusetMems("0") // .withMemory(209715200L + 2L) diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/swarm/SwarmCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/swarm/SwarmCmdIT.java index 87f35161c..36bcab840 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/swarm/SwarmCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/swarm/SwarmCmdIT.java @@ -20,6 +20,8 @@ import org.junit.experimental.categories.Category; import java.io.IOException; +import java.time.Duration; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -36,7 +38,7 @@ public abstract class SwarmCmdIT extends CmdIT { private static final String DOCKER_IN_DOCKER_IMAGE_REPOSITORY = "docker"; - private static final String DOCKER_IN_DOCKER_IMAGE_TAG = "17.12-dind"; + private static final String DOCKER_IN_DOCKER_IMAGE_TAG = "26.1.3-dind"; private static final String DOCKER_IN_DOCKER_CONTAINER_PREFIX = "docker"; @@ -105,6 +107,8 @@ protected DockerClient startDockerInDocker() throws InterruptedException { ExposedPort exposedPort = ExposedPort.tcp(2375); CreateContainerResponse response = hostDockerClient .createContainerCmd(DOCKER_IN_DOCKER_IMAGE_REPOSITORY + ":" + DOCKER_IN_DOCKER_IMAGE_TAG) + .withEntrypoint("dockerd") + .withCmd(Arrays.asList("--host=tcp://0.0.0.0:2375", "--host=unix:///var/run/docker.sock", "--tls=false")) .withHostConfig(newHostConfig() .withNetworkMode(NETWORK_NAME) .withPortBindings(new PortBinding( @@ -125,7 +129,7 @@ protected DockerClient startDockerInDocker() throws InterruptedException { DockerClient dockerClient = initializeDockerClient(binding); - await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> { + await().pollDelay(Duration.ofSeconds(5)).atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { dockerClient.pingCmd().exec(); }); diff --git a/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_empty.json b/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_empty.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_empty.json @@ -0,0 +1 @@ +{} diff --git a/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_warnings.json b/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_warnings.json new file mode 100644 index 000000000..edeaedc7a --- /dev/null +++ b/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_warnings.json @@ -0,0 +1,5 @@ +{ + "Warnings": [ + "Published ports are discarded when using host network mode" + ] +} diff --git a/docker-java/src/test/resources/com/github/dockerjava/api/model/pullImageResponse_alreadyExists.json b/docker-java/src/test/resources/com/github/dockerjava/api/model/pullImageResponse_alreadyExists.json new file mode 100644 index 000000000..ae318e29d --- /dev/null +++ b/docker-java/src/test/resources/com/github/dockerjava/api/model/pullImageResponse_alreadyExists.json @@ -0,0 +1 @@ +{"status":"Already exists"} diff --git a/pom.xml b/pom.xml index 3ada79555..4acf4e175 100644 --- a/pom.xml +++ b/pom.xml @@ -58,21 +58,21 @@ 1.8 2.30.1 - 2.10.3 - 2.10.3 + 2.18.3 + 2.18.3 4.5.12 - 1.21 - 2.13.0 - 3.12.0 + 1.27.1 + 2.18.0 + 3.17.0 1.7.30 - 1.76 - 2.6.1 - 19.0 + 1.80 + 2.10.1 + 33.4.8-jre 1.2.3 - 4.1.46.Final + 4.1.119.Final 2.2 1.8 2.3.3 @@ -148,6 +148,7 @@ ${jdk.target} ${jdk.debug} ${jdk.optimize} + true @@ -243,7 +244,7 @@ com.github.siom79.japicmp japicmp-maven-plugin - 0.18.3 + 0.23.1