spotify / docker-client

INACTIVE: A simple docker client for the JVM
Apache License 2.0
1.43k stars 548 forks source link

Using docker:dind image as docker server #1216

Closed dungbv99 closed 2 years ago

dungbv99 commented 3 years ago

Is this a BUG REPORT or FEATURE REQUEST?:

Description

I use docker:dind image as docker server with purpose deploy my project in k8s (My project require docker server to run some container)

How to reproduce

Start docker server with docker:dind image: Step 1: docker run --privileged -p 12375:2375 --name some-docker -d \ --network docker-network --network-alias docker \ -e DOCKER_TLS_CERTDIR="" \ -v some-docker-certs-ca:/certs/ca \ -v some-docker-certs-client:/certs/client \ docker:dind

Step 2 : connect my maven project with docker server: DockerClient docker = DefaultDockerClient.builder() .uri(URI.create("http://localhost:12375")) .build();

Then I config HostConfig and ContainerConfig like: HostConfig hostConfig = HostConfig.builder(). appendBinds("/home/dung/Desktop/demo/tmp_dir:/foo").build();

    ContainerConfig containerConfig = ContainerConfig.builder().
            image("gcc:8.5-buster").
            cmd("sh", "-c", "while :; do sleep 100; done").
            attachStdout(true).
            attachStdin(true).
            hostConfig(hostConfig).
            build();

    ContainerCreation containerCreation = docker.createContainer(containerConfig);

    docker.startContainer(containerCreation.id());

What do you expect

My expect is find in: /home/dung/Desktop/demo/tmp_dir appear in /foo - folder in container

It work well with my docker client like:
DockerClient docker = new DefaultDockerClient("unix:///var/run/docker.sock"); But does not work with : DockerClient docker = DefaultDockerClient.builder() .uri(URI.create("http://localhost:12375")) .build();

What happened instead

[Describe the actual results]

Software:

Full backtrace

[Paste full backtrace here]
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.