List local container services
List deployed container services; Cloud Run turns an application image into an HTTP endpoint.
Use the Cloud Run SDK over the local gRPC endpoint with a plaintext channel and no credentials. Requires JDK 17+ and Maven.
Discovery check · reads existing local state.
SDK dependencies
Run in a new example directory
cat > pom.xml <<'XML'
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId><artifactId>local-example</artifactId><version>1</version>
<dependencies><dependency>
<groupId>com.google.cloud</groupId><artifactId>google-cloud-run</artifactId><version>0.99.0</version>
</dependency></dependencies>
</project>
XML
mvn -q dependency:build-classpath -Dmdep.outputFile=classpath.txt Save as Hello.java
import com.google.api.gax.core.NoCredentialsProvider;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.rpc.FixedTransportChannelProvider;
import com.google.cloud.run.v2.*;
import io.grpc.ManagedChannelBuilder;
import java.util.Objects;
public class Hello {
public static void main(String[] args) throws Exception {
var host = Objects.requireNonNull(System.getenv("CLOUD_RUN_EMULATOR_HOST"));
var project = Objects.requireNonNull(System.getenv("GOOGLE_CLOUD_PROJECT"));
var channel = ManagedChannelBuilder.forTarget(host).usePlaintext().build();
var settings = ServicesSettings.newBuilder()
.setTransportChannelProvider(FixedTransportChannelProvider.create(GrpcTransportChannel.create(channel)))
.setCredentialsProvider(NoCredentialsProvider.create()).build();
try (var client = ServicesClient.create(settings)) {
for (var service : client.listServices("projects/" + project + "/locations/us-central1").iterateAll()) {
System.out.println(service.getName());
}
} finally {
channel.shutdownNow();
}
}
} Run the example
java --class-path "$(cat classpath.txt)" Hello.java Verify the result
The request succeeds. An empty list or no printed rows is valid before matching resources exist. Continue with the documented workflows for a resource test.