#Building docker-compose images with dagger

1 messages · Page 1 of 1 (latest)

stray gate
#

hi everyone! Im exploring the CI part of Dagger, and trying to automate the process to get the docker images ready. Im trying to build the images pointing to the description in a docker-compose, and im having docker connectivity issues:
│ ∅ .withExec(args: ["docker-compose", "-f", "/src/orch-docker-compose.yaml", "build", "globalmgmt"]): Container! 8.5s
│ ┃ Building globalmgmt
│ ┃ Couldn't connect to Docker daemon at http+docker://localhost - is it running?
│ ┃
│ ┃ If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

This is the code at this moment:
@function
async def build_and_up_service(
self,
compose_file_path: str,
service_name: str,
orch_dir: Annotated[dagger.Directory, Doc("Source directory")]
) -> str:

    basecontainer = (
        dag.container()
        .from("docker/compose:latest")
        .with_directory("/src", orch_dir)
        .with_workdir("/src")
        #.with_unix_socket(host_docker_socket, "/var/run/docker.sock") # Use the Socket object here
        # Set DOCKER_HOST environment variable just in case, though with socket mount it's often implicit
        #.with_env_variable("DOCKER_HOST", "unix:///var/run/docker.sock")
    )

and this is how im running it:
dagger call build-and-up-service --compose-file-path="/src/orch-docker-compose.yaml" --service-name=globalmgmt --orch_dir="../../../../orchestrators"
thanks in advance for the help!

bleak dust
# stray gate hi everyone! Im exploring the CI part of Dagger, and trying to automate the proc...

hey there! welcome! if you're intending to use docker-compose within Dagger, then you'll need to mount the Docker socket given that Dagger and Docker have a different API and are not interoperable by default.

What we do support is being able to build docker images via existing Dockerfiles. In that sense you can use your existing compose Dockerfiles and build the images like this: https://docs.dagger.io/cookbook/#build-image-from-dockerfile

Filesystem

stray gate
#

thanks a lot, will give it a try!

stray gate
#

trying it....

this as the runner
docker run --rm -v /var/lib/dagger -v $HOME/.config/dagger/engine.json:/etc/dagger/engine.json -v /var/run/docker.sock:/var/run/docker.sock --name dagger-engine-custom --privileged registry.dagger.io/engine:v0.18.10

this as how i connect:
_EXPERIMENTAL_DAGGER_RUNNER_HOST=docker-container://0b76f7eb86ea dagger

this as the Dagger shell:
container | from alpine | with-exec apk update | with-exec apk add docker | with-exec docker ps

and docker ps is unable to reach the unix socket