在我的 Docker (Spring Boot) 应用程序中,我想执行 Docker 命令。我使用 docker-spotify-api(客户端)。
我收到不同的连接错误。我将应用程序作为 docker-compose.yml 的一部分启动。
这是我迄今为止在 EC2 AWS VPS 上尝试过的:
docker = DefaultDockerClient.builder() .uri(URI.create("tcp://localhost:2376")) .build(); => TCP protocol not supported. docker = DefaultDockerClient.builder() .uri(URI.create("tcp://localhost:2375")) .build(); => TCP protocol not supported. docker = new DefaultDockerClient("unix:///var/run/docker.sock"); ==> No such file docker = DefaultDockerClient.builder() .uri("unix:///var/run/docker.sock") .build(); ==> No such file docker = DefaultDockerClient.builder() .uri(URI.create("http://localhost:2375")).build(); or docker = DefaultDockerClient.builder() .uri(URI.create("http://localhost:2376")).build(); or docker = DefaultDockerClient.builder() .uri(URI.create("https://localhost:2376")) .build(); ==> Connect to localhost:2376 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
这是我在 EC2 VPS 上的环境:
$ ls -l /var/run
lrwxrwxrwx 1 root root 6 Nov 14 07:23 /var/run -> ../run
$ groups ec2-user
ec2-user : ec2-user adm wheel systemd-journal docker
$ ls -l /run/docker.sock
srw-rw---- 1 root docker 0 Feb 14 17:16 /run/docker.sock
echo $DOCKER_HOST $DOCKER_CERT_PATH
(empty)