Skip to main content

Working with Container Image

Publish Container Image​

  1. Login to OneDev docker registry:

    $ docker login onedev.example.com

    Login user needs to have package write permission over the project below

  2. Then push image to desired repository under specified project:

    $ docker push onedev.example.com/<project path>/<repository>:<tag>
    ParamExplanation
    <project path>path of a project with package management enabled
    <repository>repository name of the image. Will be created automatically if not exist
    <tag>tag of the image
  3. To build and publish in CI/CD, add a Build Image step and choose registry output. Under More Settings → Registry Logins, add the OneDev server URL, user name @job_token@, and a job secret containing an access token with package write permission for the destination project. Using the job token as the user name associates the package with the publishing build.

    For example, after checking out a repository containing a Dockerfile:

    - !BuildImageStep
    name: Build and push
    output: !RegistryOutput
    tags: '@server@/my-project/my-image:@build_number@'
    registryLogins:
    - registryUrl: '@server_url@'
    userName: '@job_token@'
    passwordSecret: package-token
    condition: SUCCESSFUL

    Replace my-project/my-image with your project path and image repository, and create the package-token job secret before running the job.

note

If OneDev server is accessed via http protocol, please configure your docker daemon or buildx builder to work with insecure registry

Consume Published Image​

Open Packages and select the image tag. The detail page shows its digest, platform, login command, and pull command:

Published container image

Log in with package read permission, then pull the image:

docker login onedev.example.com
docker pull onedev.example.com/<project path>/<repository>:<tag>

The registry host must be reachable from Docker and any BuildKit containers. Configure OneDev's Server URL accordingly; localhost inside a container refers to that container, not the OneDev host.

Query Published Image​

When query published images from package list page, Name represents repository of the image, and Version represents tag of the image.