-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can fig build an image with no service/container associated ? #663
Comments
If there's a
|
There is no base container, the base image contains the common bits for all other images. It is not meant to run anything by itself. I build the base image using: The other images' Dockerfiles start with |
Sorry, I originally read "There is no base container" as your description of the problem :) If I have it right, you're not actually trying to run your containers, just build the images for them. If so, whoever told you that was Fig's job was mistaken - Fig is for running containers, and the image-building functionality only goes far as it needs to in order to enable that. |
He was not mistaken, he told me I could use fig to manage containers in a declarative way instead of my make-based approach. And it works well! So I guess I have my answer, fig can't build arbitrary images and handle dependencies between such images and container images. Am I right? |
That's right. There's talk about enabling that at the Docker level - see moby/moby#735 - but I don't really think it's Fig's job. |
I use the following pattern in project/docker-compose.yml. It seems to be working. mariadb:
build: mariadb/
volumes:
- /etc/mysql
- /var/lib/mysql
ports:
- "3306:3306"
django:
build: django/
command: /bin/true
app1:
image: project_django
links:
- mariadb
- django
ports:
- "8000" |
@DarkerMatter |
@aanand Yes using a private docker-registry might be more advisable solution, but I think this kind of pattern can have it's place |
@fruch app1 is just an example of using the django image created. For instance app2 could have different volumes/db/ports, etc. |
@fruch also, as fig/compose works out the dependencies, it makes sure that the django image is built before app1 in a fresh installation |
From what I can remember from two-ish years ago, I tried to hack on fig to add a way to express dependencies between images but didn't manage to reliably do it because there were too many moving parts. Building the dependency graph by reading the FROM clause of the Dockerfiles was also feeling somewhat wrong. Then my use case retired. By the time I was done with it my Makefile had been good-enough and I moved on to other work. Looking at @DarkerMatter's workaround, it could work and help create the base image at the expense of creating a throwaway container. I'm not sure it would guarantee the image creation order. I haven't tried. Sorry |
@dridi I figured this was long ago, far away for you at this point :). Yeah, I just have a shell script that builds these base images. Definitely good enough. Thank you! |
I'm just starting with fig so it may just be a case of not reading properly the docs, but I haven't found out how to just build an image with fig. I'm trying to replace a make-based approach after someone told me a couple months ago that I was basically doing what fig does. I was also waiting for fig 1.0 to land in Fedora, which is almost there.
But I have a base image, which is basically based on
centos:centos6
, installs and enables EPEL, and a private YUM repository. I use this image as a base for all the containers, and incidentally benefit from caching and DRY.Conceptually, it looks a bit like this:
Now I can create and run
db
andfront
containers, and link them together, but I have built thebase
image separately. There is nobase
container.Did I miss something?
The text was updated successfully, but these errors were encountered: