Giter VIP home page Giter VIP logo

docker-hub's Introduction

Docker Hub CLI

PyPI version Build Status Coverage Status

asciicast

A CLI tool to access Docker Hub from your terminal.

Installation

Note: Minimum Python 3.7 is required.

You should have pip installed in your system.

pip install docker-hub

If you have Python 2 also in the system do:

pip3 install docker-hub

Usage

1. Authenticate with Docker Hub

If you are already logged in using docker login command, then the token in Docker engine config will be used. Otherwise you can choose to proceed without authenticating which will query docker hub without token and list only public resources. To authenticate for viewing private resources do docker-hub login command; this will save auth token in docker-hub's config file so that you don't need to login every time.

If you want to authenticate for the only current command (to not persist auth tokens in config), make use of the following env variables:

  • DOCKER_HUB_USERNAME - Your Docker Hub username
  • DOCKER_HUB_PASSWORD - Your Docker Hub password

Pass the mentioned envs with your command and docker-hub will try to do authentication without prompting for credentials.

e.g.:

DOCKER_HUB_USERNAME=hello DOCKER_HUB_PASSWORD=world docker-hub repos --orgname docker
2. Querying an organization for repositories

To query repositories in an organization use repos argument. The organization to query can be passed as --orgname or -o parameter.

e.g.: Get repos in organization named "docker"

docker-hub repos --orgname docker
3. Querying the tags of a repository

To query tags of a repository use tags argument. The organization of repository can be passed as --orgname or -o parameter. The repository to query can be passed as --reponame or -r parameter.

e.g.: Get tags of repository "ucp" in organization named "docker"

docker-hub tags --orgname docker --reponame ucp

If you want to display all pages result then use option --all-pages or -a

docker-hub tags --orgname docker --reponame ucp --all-pages
4. Querying a user profile

To query a user profile use users argument. The username to query can be passed as --username or -u parameter.

e.g.: Get profile of user named "docker"

docker-hub users --username docker
5. Querying the auto-builds of a repository

To query auto-builds of a repository use builds argument. The organization of repository can be passed as --orgname or -o parameter. The repository to query can be passed as --reponame or -r parameter.

e.g.: Get build of repository "ucp" in organization named "docker"

docker-hub builds --orgname docker --reponame ucp
6. Querying an organization for auto-build queue

To query the auto-build repositories with pending builds use the queue argument. The organization to query can be passed as --orgname or -o parameter.

e.g.: Get the building queue for organization named "docker"

docker-hub queue --orgname docker
7. Setting and getting config values

Config values can be set or get using config argument. Currently supported config names:

  • orgname - orgname to use in case of --orgname is not provided.

A config can be set using set command and passing config name along with it's corresponding value.

e.g.: Set value for config "orgname"

docker-hub config set orgname docker

A config value can be get using get command and passing config name.

e.g.: Get value for config "orgname"

docker-hub config get orgname

To list all config values that are currently present:

docker-hub config
Notes:
  • Only 15 results will be displayed at once. You can fetch remaining pages by passing --page or -p parameter.

    e.g.: Get 3rd page

    docker-hub repos --orgname docker --page 3
  • The results can be displayed in 2 formats:

    1. json - Displays result as JSON string.
    2. table - Displays results as nicely formatted table.

    --format or -f parameter can be used to specify the format in which result must be displayed.

    e.g.:

    • Display in json format
    docker-hub repos --orgname docker --format json
    • Display in table format
    docker-hub repos --orgname docker --format table

Development

Questions, problems or suggestions? Please post them on the issue tracker.

You can contribute changes by forking the project and submitting a pull request. Feel free to contribute ๐Ÿ˜

UNDER MIT LICENSE

The MIT License (MIT)

Copyright (c) 2016 Amal Francis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

docker-hub's People

Contributors

amalfra avatar avoinea avatar jessestuart avatar sdahlbac avatar sodul avatar tomviner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

docker-hub's Issues

Is there a way to override DOCKER_HUB_API_ENDPOINT

As there are becoming more and more docker registries it would be nice to be able to query them as well.
Is there a option to override the DOCKER_HUB_API_ENDPOINT and or would u consider it useful to make it configurable?

Running within a container

I ran this:

IMG_NAME="python:3.6.5-alpine3.7"
echo && echo && docker run --rm -it \
"$IMG_NAME" sh;

Then I can install docker but it does run. I can't restart as I will lose my install. It's the classic DinD problem. Do you have a quick solution to propose?

Thanks!
Pascal

Improvements

It would be nice to align the commands with docker-compose ones. We can also inspire from rancher cli

  • 1. For example, instead of providing the --orgname each and every time, we can do:

      $ docker-hub config
      Url: DOCKER_HUB_API_ENDPOINT
      Organization Name: ...
      Items per page: ...
    
  • 2. Rename repos to images (after all, they are images)

      $ docker-compose images
      $ docker-hub images
    
  • 3. Rename queue to ps

      $ docker-hub ps
    
  • 4. Move global options before commands and provide a short version:

      $ docker-hub --orgname docker images
      $ docker-hub -o docker images
    

cannot login

On osx

docker-hub version
docker-hub 4.0.0

docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
<redacted>
Login Succeeded

 docker-hub repos --orgname <notrelevant>
##################################
 Found 5 results. On page 1 of 1
##################################
+---------------+-------------------+--------------+--------------+------------------+
| Name          | Repository Type   |   Star count |   Pull count | Last updated     |
+===============+===================+==============+==============+==================+
| apple-bloom   |                   |            0 |         2508 | 2016-10-20 09:20 |
+---------------+-------------------+--------------+--------------+------------------+
| ubuntu        | image             |            0 |          446 | 2018-08-14 06:56 |
+---------------+-------------------+--------------+--------------+------------------+
| centos        | image             |            0 |          231 | 2017-06-22 13:48 |
+---------------+-------------------+--------------+--------------+------------------+
| wine-electron | image             |            0 |         3488 | 2021-12-06 17:09 |
+---------------+-------------------+--------------+--------------+------------------+
| agent         | image             |            0 |            6 | 2021-10-01 13:32 |
+---------------+-------------------+--------------+--------------+------------------+

**Tip: You are not authenticated with Docker Hub. Hence only public resources will be fetched. Try authenticating using `docker login` or `docker-hub login` command to see more.**
 docker-hub login
Traceback (most recent call last):
  File "/opt/homebrew/bin/docker-hub", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/src/__main__.py", line 78, in main
    command.run(docker_hub_client, args)
TypeError: run() takes 1 positional argument but 2 were given

Automated Build from Pushed Local Folder

I'm not sure if this is possible from the Docker hub side, but it would be really handy if there was a way to support a Zeit Now style mechanic whereby I could push a build directory to Docker hub and then let Docker hub build the container remotely for me - essentially, an automated build from an uploaded archive model.

Docker Hub is capable of pulling content from a Github repo as part of an automated build - the question is, can the automated build be co-opted so we can push repo contents ourselves to the automated build endpoint on Docker hub?

Running docker-hub without any prompts

Continuing from #6 (comment)

I would love to launch this container without any prompts.

I feel it would be valuable to have a config file where we could configure:

DOCKERHUB_USER=myuser1234
DOCKERHUB_PASS=h5h356h356hy

This way we could build a Dockerfile and run the image without interactions.

The VARS could also be passed along when running the container and override the default VARS:
Per example:

IMG_NAME="myuser:dockerhub-cli:1.0" \
\
echo && echo && docker run --rm -it \
-e DOCKERHUB_USER=myuser1234 \
-e DOCKERHUB_PASS=h5h356h356hy \
"$IMG_NAME" \
\
sh -c 'docker-hub users --username docker';

Hope it make sense :)

Fix `site-packages/src` installation directory

Thanks for providing this tool. I was looking at the possibility of using it as a library for our own python projects and I noticed that it does not get pip installed cleanly.

The src directory get installed in site-packages as src which means that if someone else does the same thing the directories will clash.

I strongly recommend that you rename the src directory to docker_hub and update the referenced accordingly.

Today we can do:

import src.libs.docker_hub_client

And being able to do:

import docker_hub.libs.docker_hub_client

would be much cleaner.

I can send a PR if you are interested. The changes should be minimal.

If you enjoy this project, say thanks here!

Here is the place to say thank you to folks who are working hard on this project.

ยซ One of the greatest ways to show your appreciation to open source projects you enjoy is to open an issue that let people say thank you ยป

Disclaimer: I don't have any kind of connexion or personal interest with maintainers(s) of this project. Pure gratitude here.

Cheers!

KeyError: 'description' in repos command

Suddenly just started to get this error from version 3.0.0 of the library:

$ docker-hub repos -o rapidsai
Traceback (most recent call last):
  File "/Users/rdouglass/miniforge3/envs/dockerhubtest/bin/docker-hub", line 8, in <module>
    sys.exit(main())
  File "/Users/rdouglass/miniforge3/envs/dockerhubtest/lib/python3.9/site-packages/docker_hub/cli.py", line 74, in main
    command.run(docker_hub_client, args)
  File "/Users/rdouglass/miniforge3/envs/dockerhubtest/lib/python3.9/site-packages/docker_hub/commands/repos.py", line 23, in run
    rows.append([repo['name'], repo['description'],
KeyError: 'description'

It looks like description isn't provided by the API anymore.

Problems authenticating

(on osx)

Enter docker hub username: myuser
Enter docker hub password:
auth_token is not a valid config name

Login Succeeded

 > cat ~/.docker-hub/config.json
{}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.