ansible / ansible-container

DEPRECATED -- Ansible Container was a tool to build Docker images and orchestrate containers using only Ansible playbooks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Full customization of the Docker (or other) registry path for a project?

geerlingguy opened this issue · comments

ISSUE TYPE
  • Feature Idea
container.yml
version: "2"
settings:
  conductor_base: debian:9

services:
  solr:
    from: "debian:9"
    ports:
      - "8983:8983"
    command: ["/opt/solr/bin/solr", "start", "-f", "-force"]
    roles:
      - setup
      - geerlingguy.java
      - geerlingguy.solr
    dev_overrides:
      environment:
        - "DEBUG=1"

registries:
  docker:
    url: https://docker.io
    namespace: geerlingguy
    repository_prefix: ''
OS / ENVIRONMENT

https://gist.github.com/geerlingguy/b4a89f1b8f9a03ad5537e39f82934c93

SUMMARY

When I push my built container image to a repository (Docker, in this case), I seem to have some control—but not complete control—over the namespace and registry name.

I want to push to docker.io/geerlingguy/solr, but no matter what I try, Ansible Container pushes to docker.io/[namespace]/[not-sure-where-coming-from]-solr

STEPS TO REPRODUCE

Use above container.yml, build it, then run:

 ansible-container push --push-to docker --username geerlingguy --tag latest
EXPECTED RESULTS

It would push to docker.io/geerlingguy/solr.

ACTUAL RESULTS
Parsing conductor CLI args.
Engine integration loaded. Preparing push.	engine=Docker™ daemon
Tagging docker.io/geerlingguy/acsolr-solr
Pushing docker.io/geerlingguy/acsolr-solr:latest...
The push refers to a repository [docker.io/geerlingguy/acsolr-solr]
...

Basically, I want to get rid of that acsolr-, and I don't know where it's coming from.

Doing some further debugging, it looks like the prefix I want to get rid of is the directory name of the project. E.g. if I change the directory locally from acsolr to solr, then the path becomes docker.io/geerlingguy/solr-solr.

This is kind of annoying, since I often have local GitHub projects cloned into folders that are not the same name as the actual upstream repo for various reasons. It would be nice if there was a repository parameter (alongside namespace and repository_prefix—the latter of which I'm not sure what it does) like prepend_directory that I could put as false to just have solr (the service's name).

Also, note that this is in reference to this repository: https://github.com/geerlingguy/ac-solr (in case you want to do any testing).

Yeah, the default behavior is to tag the image with the project name + the service name. It happens in docker/engine.py.

We either remove the project name altogether, or we add a directive that lets you override the resulting image name. The reason it's there, I think, is to prevent name collision in the local dev environment.

I notice you have the registry_prefix set to '', here. Maybe if it's set to '', then we should not insert the project_name.

I notice you have the registry_prefix set to '', here. Maybe if it's set to '', then we should not insert the project_name.

That behavior makes sense to me; for anyone using ansible-container to build and manage more generic containers/sets of containers, it's nice to have the flexibility of naming the tags with just service instead of project-service.