#How to load image from tar?
1 messages · Page 1 of 1 (latest)
I have this image in my local Docker hub which I want to use in Dagger, this seems like the easiest way (since the image is used in a yml file) but I couldn't quite find the proper way of using it
Ah, you've hit something that's not quite possible yet
the issue to track in the meantime is https://github.com/dagger/dagger/issues/10737
yeah, you can use the .DockerBuild function to build a docker image
i would say - this is probably coming soon-ish? i've been working on this area a lot recently, so want to get this working properly
But what if I want just the image, not a container? (I see that .DockerBuild gives me a container)
Cause the image is used in a yml file for a Docker Compose, stuff is messy
Also, on a sidenote, I assume healthchecks defined in said yml file are respected by the inner Docker daemon (dind), right? This would be another reasoning, those healthchecks are used in the setup process and since Dagger has no withHealthcheck I found it to be a pain to do it by hand (and also ran into multiple issues)
In dagger, there's not really a difference between a container and an image
you can think of each WithExec in a pipeline as similar to a RUN step in a dockerfile
they all build layers
what do you mean by inner docker daemon? dagger uses it's own container runtime, there's no docker inside
Oh, ok, but since Dagger by default ignores entrypoint, and my Dockerfile has one, do I have to do something like
.withExec(nil, dagger.ContainerWithExecOpts{
UseEntrypoint: true,
})
``` for it to be respected?
Sorry if my terminology is bad, I'm new at this. The thing is, if I do docker-compose in dagger, that's Docker-in-Docker, right?
oh i see, you're running docker-compose in dagger
yeah, if you're running docker-compose in dagger, then it'll work just as normal docker-compose does
Can't you also docker save and container().import() ? as a stopgap
i need to wake up
of course import is a thing
So I have
blockchain := dag.Container().
WithMountedDirectory("/src", source).
WithWorkdir("/src").
Import(source.File("localcontract:latest.tar"))
which is how I hope it works. But do I have to run it as service for the other container to access it? As for the entrypoint, I don't actually run anything inside it, I only need it as an image (so no withExec 😦 ), and the yml file in question just pulls the image
blockchain:
container_name: blockchain
image: localcontract:latest
ports:
- 8545:8545
volumes:
- configs-volume:/usr/src/app/configs
healthcheck:
test:
- CMD-SHELL
- find deployment_completed.txt || exit 1
interval: 1m
timeout: 5s
retries: 30
start_period: 15s
Note @proud compass : for rapid experimentation you can call the dagger API from dagger shell. Example:
dagger <<.
source() {
host | directory ./path/to/your/source/dir
}
container |
with-mounted-directory /src $(source) |
with-workdir /src |
import $(source | file localcontract:latest.tar)
.
Ok, I'll keep that in mind! However, how does that help my problem? 😅
Not directly - just mentioning it, since it can help you iterate faster
I don't completely understand your problem, got lost in the many messages
Where are you stuck @proud compass ?
You may need to do the import first:
blockchain := dag.Container().
Import(source.File("localcontract:latest.tar"))
WithMountedDirectory("/src", source)
WithWorkdir("/src").
Sorry for the delay, I ate lunch
I'm stuck at how to actually use the image (/container) in the actual container where I'm using docker-compose on the .yml file which I shared a snippet from. So, the yml would run blockchain as service itself, but because of this setup, do I have to run it myself? Something like
blockchain := dag.Container().
Import(source.File("localcontract:latest.tar")).
WithMountedDirectory("/src", source).
WithWorkdir("/src").
WithExposedPort(8545).
WithMountedCache("/usr/src/app/configs", dag.CacheVolume("configs-volume")).
AsService() // and then also a manual healthcheck
to mimick what the .yml does. It just seems like too much of a hassle since the .yml does this already but idk what else to do.
I guess it depends what you're trying to achieve in the end.
Do you have a clear picture of how you want to fit dagger in your stack, or is that what you're trying to figure out?
I'm trying to figure out if I can do this workaround. Currently the team gets the image from ECR but they told me to simulte the CI/CD pipeline locally, which is why I have this headache