Skip to content
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

Issue pulling from Private Repository #118

Closed
Mythirion opened this issue Oct 5, 2020 · 6 comments
Closed

Issue pulling from Private Repository #118

Mythirion opened this issue Oct 5, 2020 · 6 comments

Comments

@Mythirion
Copy link

Hi,

We're moving over to Ofelia from docker-crontab because we want alerts when the cronjobs don't quite work. Having some trouble at the minute getting Ofelia to work with our private GitLab repository, however.

We have a test job, called foo-bar, for example:

[job-run "foo-bar"]
schedule = @every 5m
image = private-gitlab-repo-image:image_sha
command = /scripts/testScript.sh
volume = test/ofelia/directory:/mnt/directory
delete = true
pull = true

I also have a Dockerfile (added the docker login for the private repo):

FROM mcuadros/ofelia

RUN apk add docker && docker login -u [deploy-token] -p [password] [repo]
COPY config.ini /etc/ofelia/config.ini

And a docker-compose (we use docker-compose in prod. Also mounted my config.json because I read somewhere that you need to add it to work with private repos. Doesn't work without it either):

version: '3.6'

services:
  ofelia:
    build: ofelia/
    networks:
      - default
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /tmp/log/ofelia:/var/log/crontab
      - /home/user/.docker/config.json:/root/.docker/config.json

Then, I'm simply running docker-compose up --build to build and run the 'stack'.

I'm getting the error:

ofelia_1  | scheduler.go:35 ▶ NOTICE New job registered "foo-bar" - "/scripts/testScript.sh" - "@every 5m"
ofelia_1  | scheduler.go:55 ▶ DEBUG Starting scheduler with 1 job
ofelia_1  | common.go:124 ▶ NOTICE [Job "foo-bar" (18b59c2be7a5)] Started - /scripts/testScript.sh
ofelia_1  | common.go:120 ▶ ERROR [Job "foo-bar" (18b59c2be7a5)] Finished in "1.425492638s", failed: true, skipped: false, error: couldn't find image on the host

One would assume from the code that (especially after adding pull = true to the config.ini file) it should try to pull the image first.

How do I fix this?

Thanks

@taraspos
Copy link
Collaborator

taraspos commented Oct 5, 2020

Hey @Mythirion ,

docker login on creates create config entry similar to:

    "registry.gitlab.com": {
            "auth": "bas64decodeduserandpassowrd==",
            "email": "your email"
    }

where bas64decodeduserandpassowrd== is created by echo -n 'username:password' | base64

So when providing an image you need to provide full image name like:

image = registry.gitlab.com/my_image:my_tag

This way application will know to take credentials for registry.gitlab.com from the config.

Can you try that and let me know if that works for you?

@Mythirion
Copy link
Author

Hi @trane9991,

I can confirm that the URL in config.json and the start of the image URL in image = are the same.

Cheers

@Mythirion
Copy link
Author

Forgot to add, using an alpine image seems to get pulled fine, which leads me to believe there's an issue with third-party, private registries.

@taraspos
Copy link
Collaborator

taraspos commented Oct 5, 2020

One would assume from the code that (especially after adding pull = true to the config.ini file) it should try to pull the image first.

This is the correct assumption, with the pull = true it does try to pull the image first, however, it looks for image locally when pull failed and an error returned from the second operation only.

So the problem must be with image pulling.

Can you please share with me the exact format of your private image name and entry in the config.json (removing the sensitive data of course)?

@taraspos
Copy link
Collaborator

taraspos commented Oct 5, 2020

Hi @trane9991,

I can confirm that the URL in config.json and the start of the image URL in image = are the same.

Cheers

Are they completely-completely the same?
Maybe the URL in the config.json has https:// prefix and the image in the config.ini don't have it?

@Mythirion
Copy link
Author

Hi @trane9991,

We got a little confused with credentials and logging in on the host. We can now confirm that it works.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants