Me need take value from group vars and download some image from dockerhub, but value put incorrectly.
My playbook:
hosts: all
tasks:
name: download image
docker_image:
name:
- "{{image}}"
source: pull
My group_vars
image:
nginx
ubuntu
And error message:
fatal: [linux1]: FAILED! => {"changed": false, "msg": "Error pulling image ['((image))']:latest - 400 Client Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=%5B%27%28%28image%29%29%27%5D: Bad Request (\"invalid reference format\")"}
I tried different syntax variant and update my app
I understand this problem. docker_image just requires specifying tags
The name argument to the docker_image module should be a string, not a list:
- hosts: all
tasks:
- name: download image
docker_image:
name: "{{image}}"
source: pull
Related
Is there a way to use private images from a registry with authentication for custom GitHub Docker container actions? Would like to point at runs.image to a private docker image. Ideally, one which is uploaded to a GitHub Packages registry.
# action.yml
name: 'Hello World'
description: 'Greet someone'
inputs:
who_to_greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.who_to_greet }}
https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
I'm trying to make my first action to build packages inside a given docker container. I have the following action.yaml file:
name: Build Package
description: Build Debian packages using Docker image
inputs:
docker_image:
description: Name of the docker image to use
required: true
runs:
using: 'composite'
steps:
- name: Check out the repository
uses: actions/checkout#v2
- name: Build `*.deb` packages
uses: 'docker://${{inputs.docker_image}}'
with:
entrypoint: ./build.sh
In the other repository I'm trying to use it:
...
steps:
- uses: CMakeify-me/build-package-action#v1-beta
with:
docker_image: 'cmakeifyme/debian-9-deb-build:1.3'
Unfortunately, I've got the error:
Error: CMakeify-me/build-package-action/v1-beta/action.yaml (Line: 19, Col: 13):
Error: CMakeify-me/build-package-action/v1-beta/action.yaml (Line: 19, Col: 13): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.docker_image
Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. CMakeify-me/build-package-action/v1-beta/action.yaml (Line: 19, Col: 13): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.docker_image
at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check()
at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Fail to load CMakeify-me/build-package-action/v1-beta/action.yaml
Trying just print the inputs works fine:
- name: Spam
run: echo '${{ inputs.docker_image }}'
shell: bash
Meaning, that there is some problem when inputs.docker_image is used within the value of uses: ;-(
How can I pass the docker image name to be used in my action?
Thank you.
I don't think you can't use an input/variable with uses like that.
This is not explicitly mentioned in the documentation but you can see a warning here: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
Warning: When creating workflows and actions, you should always consider whether your code might execute untrusted input from possible attackers.
If you need to dynamically pick your docker container, you might have to look into an alternative. You can avoid uses and run docker from shell directly, like this...
Call your action, and pass the input via with:
- uses: CMakeify-me/build-package-action#v1-beta
with:
docker_image: 'cmakeifyme/debian-9-deb-build:1.3'
Then your action can us the input via run, using shell to call docker:
- name: run docker with dynamic image name
run: 'docker run ${{ inputs.docker_image }}'
shell: bash
I'm using JFrog repository as my private registry. And I have specified the secret in order to authenticate with the JFrog. But it says
Failed to pull image "private_registry/image_name": rpc error: code = Unknown desc = failed to pull and unpack image "private_registry/image_name": failed to resolve reference "": failed to authorize: failed to fetch oauth token: unexpected status: 401 Unauthorized
Warning Failed 2s (x2 over 14s) kubelet, worker-0 Error: ErrImagePull
I have created a secret file too. But still it doesn't pull the image. When I do docker image pull private_registry/image_name the image get pulled.
From the question, it's clear that it's not able to authenticate for some reason,
It could be a misconfiguration of the secret also possible that the credential used is/are not valid.
Since the secret.yaml file is not present, not aware of the format.
In this case, I would suggest looking at 2 things
Check if the credentials are correct. (In this case, probably you can use docker pull after docker login with the same credential)
If you are able to pull the image successfully, take a look at the next point.
In this, you have the check the way you configure or pass the credentials in the chart is correct.
There are different ways to pass credentials in different cases,
you can take a look at this official doc.
and here in devops exchange the answer also might help to get some insight.
and here is how my secret.yaml looks like:
---
apiVersion: v1
kind: Secret
metadata:
name: {{ .Chart.Name }}-docker-credentials
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Chart.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
type: kubernetes.io/dockercfg
data:
.dockercfg: {{ "{\".Values.REGISTRY.URL>>/\":{\"username\":\".Values.REGISTRY.USER_NAME>>\",\"password\":\".Values.REGISTRY.PASSWORD>>\",\"email\":\".Values.REGISTRY.EMAIL>>\",\"auth\":\".Values.REGISTRY.AUTH_TOKEN>>\"}}" | b64enc | quote }}
in the deployments i do:
spec:
imagePullSecrets:
- name: {{ .Chart.Name }}-docker-credentials
Since you have already resolved, hope this would help someone else.😃
could somebody help me, please?
I try to build and publish my image to a private docker registry:
kind: pipeline
name: default
steps:
- name: docker
image: plugins/docker
settings:
username: ****
password: ****
repo: https://*****.com:5000/myfirstimage
registry: https://*****.com:5000
tags:
- latest
But got the next error:
Error parsing reference: "https://*****.com:5000/myfirstimage:latest" is not a valid repository/tag: invalid reference format
15921 time="2020-10-18T17:52:20Z" level=fatal msg="exit status 1"
But, when I try to push manually, all is ok.
What am I doing wrong? Will be grateful for any help.
It is not common to include the scheme in the address to docker registry and repo.
Try to write those addresses without https:// as in
repo: <registry-hostname>.com:5000/myrepo/myfirstimage
registry: <registry-hostname>.com:5000
I'm trying to build and push image with drone.io's plugins/docker, but it seems cannot find my repo name.
Here is the last log about the build step.
---> Running in afca20280587
Removing intermediate container afca20280587
---> cb05c781a4c4
Successfully built cb05c781a4c4
Successfully tagged caa418f0605dc7a6b2bc84faebabac55a09a373b:latest
+ /usr/local/bin/docker tag caa418f0605dc7a6b2bc84faebabac55a09a373b :latest
Error parsing reference: ":latest" is not a valid repository/tag: invalid reference format
time="2019-01-02T02:05:18Z" level=fatal msg="exit status 1"
The sixth line should be
+ /usr/local/bin/docker tag caa418f0605dc7a6b2bc84faebabac55a09a373b registry.cn-beijing.aliyuncs.com/xxx/xxx_xxx:latest
But now it didn't find my repo name.
It's drone/drone:1.0.0-rc.3, and here is my .drone.yml
kind: pipeline
name: default
steps:
- name: build
image: python:3.6
commands:
- pip install -r requirements.txt
- python -m pytest app.py
when:
branch: master
event:
- push
- pull_request
- name: publish
image: plugins/docker
registry: registry.cn-beijing.aliyuncs.com
repo: xxx/xxx_xxx
tags: [ latest ]
username:
- from_secret: ali_username
password:
- from_secret: ali_password
Is there something wrong? Thanks for any tip!
When you define the repository you need to use the fully qualified image name:
- repo: xxx/xxx_xxx
+ repo: registry.cn-beijing.aliyuncs.com/xxx/xxx_xxx
In addition, all of the plugin settings need to be declared inside the settings block [1] like this:
- name: publish
image: plugins/docker
settings:
registry: registry.cn-beijing.aliyuncs.com
repo: registry.cn-beijing.aliyuncs.com/xxx/xxx_xxx
username:
- from_secret: ali_username
password:
- from_secret: ali_password
[1] http://plugins.drone.io/drone-plugins/drone-docker/