⚡ L1L`XPL0IT
8.2.34 | Linux | www-data (uid:33)
✏️ Edit: docker.py
📁 /snap/google-cloud-cli/503/lib/surface/docker.py
# -*- coding: utf-8 -*- # # Copyright 2014 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Enable Docker CLI access to Google Container Registry. Sets Docker up to authenticate with Container Registry, and passes all flags after `--` to the Docker CLI. """ import argparse from googlecloudsdk.calliope import arg_parsers from googlecloudsdk.calliope import base from googlecloudsdk.calliope import exceptions from googlecloudsdk.core import log from googlecloudsdk.core.docker import client_lib as docker_client_utils from googlecloudsdk.core.docker import constants from googlecloudsdk.core.docker import docker # By default, we'll set up authentication for these registries. # If the user changes the --server argument to something not in this list, # we'll just give them a warning that they're using an unexpected server. _DEFAULT_REGISTRIES = constants.DEFAULT_REGISTRIES_TO_AUTHENTICATE _DEPRECATION_WARNING = """\ `gcloud docker` will not be supported for Docker client versions above 18.03. As an alternative, use `gcloud auth configure-docker` to configure `docker` to use `gcloud` as a credential helper, then use `docker` as you would for non-GCR registries, e.g. `docker pull gcr.io/project-id/my-image`. Add `--verbosity=error` to silence this warning: `gcloud docker --verbosity=error -- pull gcr.io/project-id/my-image`. See: https://cloud.google.com/container-registry/docs/support/deprecation-notices#gcloud-docker """ @base.ReleaseTracks(base.ReleaseTrack.GA) @base.Deprecate(is_removed=False, warning=_DEPRECATION_WARNING) class Docker(base.Command): """Enable Docker CLI access to Google Container Registry. {command} wraps Docker commands so that `gcloud` can inject the appropriate fresh authentication token into requests that interact with the Docker registry. All Docker-specific flags are passed through to the underlying `docker` command. A full reference of Docker's command line options available after `--` can be found here: [](https://docs.docker.com/engine/reference/commandline/cli/). You may also run `{command} -- --help` to view the Docker CLI's help directly. Detailed documentation on Container Registry can be found here: [](https://cloud.google.com/container-registry/docs/) ## EXAMPLES To pull the image '{registry}/google-containers/pause:1.0' from the docker registry, run: ``` {command} -- pull {registry}/google-containers/pause:1.0 ``` Push the image '{registry}/example-org/example-image:latest' to our private docker registry. ``` {command} -- push {registry}/example-org/example-image:latest ``` Configure authentication, then simply use docker: ``` {command} --authorize-only docker push {registry}/example-org/example-image:latest ``` """ detailed_help = { 'registry': constants.DEFAULT_REGISTRY, } @staticmethod def Args(parser): parser.add_argument( '--server', '-s', type=arg_parsers.ArgList(min_length=1), metavar='SERVER', help='Address of the Google Cloud Registry.', required=False, default=_DEFAULT_REGISTRIES) parser.add_argument( '--authorize-only', '-a', help='Configure Docker authorization only; do not launch the ' 'Docker command-line.', action='store_true') parser.add_argument( '--docker-host', help='URL to connect to Docker Daemon. Format: tcp://host:port or ' 'unix:///path/to/socket.') parser.add_argument( 'docker_args', nargs=argparse.REMAINDER, default=[], help='Arguments to pass to Docker.') def Run(self, args): """Executes the given docker command, after refreshing our credentials. Args: args: An argparse.Namespace that contains the values for the arguments specified in the .Args() method. Raises: exceptions.ExitCodeNoError: The docker command execution failed. """ if args.account: # Since the docker binary invokes `gcloud auth docker-helper` through # `docker-credential-gcloud`, it cannot forward the command line # arguments. Subsequently, we are unable to set the account (or any # flag for that matter) used by `docker-credential-gcloud` with # the global `--account` flag. log.warning('Docker uses the account from the gcloud config.' 'To set the account in the gcloud config, run ' '`gcloud config set account <account_name>`.') with base.WithLegacyQuota(): force_refresh = True for server in args.server: if server not in _DEFAULT_REGISTRIES: log.warning( 'Authenticating to a non-default server: {server}.'.format( server=server)) docker.UpdateDockerCredentials(server, refresh=force_refresh) # Only force a refresh for the first server we authorize force_refresh = False if args.authorize_only: # NOTE: We don't know at this point how long the access token we have # placed in the docker configuration will last. More information needs # to be exposed from all credential kinds in order for us to have an # accurate awareness of lifetime here. log.err.Print('Short-lived access for {server} configured.'.format( server=args.server)) return docker_args = args.docker_args or [] docker_args = ( docker_args if not args.docker_host else ['-H', args.docker_host] + docker_args) result = docker_client_utils.Execute(docker_args) # Explicitly avoid displaying an error message that might # distract from the docker error message already displayed. if result: raise exceptions.ExitCodeNoError(exit_code=result) return
Cancel
💻 Terminal
📤 Upload
📂
Click or Drag & Drop
📁 /snap/google-cloud-cli/503/lib/surface
/
/
snap
/
google-cloud-cli
/
503
/
lib
/
surface
Name
Size
Perm
Modified
Actions
📁 __pycache__/
-
0775
2026-09-29 12:17
🗑 Delete
📁 access_approval/
-
0775
2026-09-29 12:17
🗑 Delete
📁 access_context_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 active_directory/
-
0775
2026-09-29 12:17
🗑 Delete
📁 agent_identity/
-
0775
2026-09-29 12:17
🗑 Delete
📁 agent_registry/
-
0775
2026-09-29 12:17
🗑 Delete
📁 agentic_applications/
-
0775
2026-09-29 12:17
🗑 Delete
📁 ai/
-
0775
2026-09-29 12:17
🗑 Delete
📁 ai_platform/
-
0775
2026-09-29 12:17
🗑 Delete
📁 alloydb/
-
0775
2026-09-29 12:17
🗑 Delete
📁 alpha/
-
0775
2026-09-29 12:17
🗑 Delete
📁 anthos/
-
0775
2026-09-29 12:17
🗑 Delete
📁 api_gateway/
-
0775
2026-09-29 12:17
🗑 Delete
📁 api_registry/
-
0775
2026-09-29 12:17
🗑 Delete
📁 apigee/
-
0775
2026-09-29 12:17
🗑 Delete
📁 apihub/
-
0775
2026-09-29 12:17
🗑 Delete
📁 app/
-
0775
2026-09-29 12:17
🗑 Delete
📁 app_lifecycle_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 app_optimize/
-
0775
2026-09-29 12:17
🗑 Delete
📁 app_topology/
-
0775
2026-09-29 12:17
🗑 Delete
📁 apphub/
-
0775
2026-09-29 12:17
🗑 Delete
📁 artifacts/
-
0775
2026-09-29 12:17
🗑 Delete
📁 asset/
-
0775
2026-09-29 12:17
🗑 Delete
📁 assured/
-
0775
2026-09-29 12:17
🗑 Delete
📁 audit_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 auth/
-
0775
2026-09-29 12:17
🗑 Delete
📁 authz_toolkit/
-
0775
2026-09-29 12:17
🗑 Delete
📁 backup_dr/
-
0775
2026-09-29 12:17
🗑 Delete
📁 batch/
-
0775
2026-09-29 12:17
🗑 Delete
📁 beta/
-
0775
2026-09-29 12:17
🗑 Delete
📁 beyondcorp/
-
0775
2026-09-29 12:17
🗑 Delete
📁 biglake/
-
0775
2026-09-29 12:17
🗑 Delete
📁 bigtable/
-
0775
2026-09-29 12:17
🗑 Delete
📁 billing/
-
0775
2026-09-29 12:17
🗑 Delete
📁 blockchain_node_engine/
-
0775
2026-09-29 12:17
🗑 Delete
📁 blockchain_validator/
-
0775
2026-09-29 12:17
🗑 Delete
📁 bms/
-
0775
2026-09-29 12:17
🗑 Delete
📁 bq/
-
0775
2026-09-29 12:17
🗑 Delete
📁 builds/
-
0775
2026-09-29 12:17
🗑 Delete
📁 cbrs_spectrum_access/
-
0775
2026-09-29 12:17
🗑 Delete
📁 certificate_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 cloud_shell/
-
0775
2026-09-29 12:17
🗑 Delete
📁 cloudlocationfinder/
-
0775
2026-09-29 12:17
🗑 Delete
📁 cluster_director/
-
0775
2026-09-29 12:17
🗑 Delete
📁 code/
-
0775
2026-09-29 12:17
🗑 Delete
📁 colab/
-
0775
2026-09-29 12:17
🗑 Delete
📁 commerce_procurement/
-
0775
2026-09-29 12:17
🗑 Delete
📁 compliance_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 components/
-
0775
2026-09-29 12:17
🗑 Delete
📁 composer/
-
0775
2026-09-29 12:17
🗑 Delete
📁 compute/
-
0775
2026-09-29 12:17
🗑 Delete
📁 config/
-
0775
2026-09-29 12:17
🗑 Delete
📁 container/
-
0775
2026-09-29 12:17
🗑 Delete
📁 data_catalog/
-
0775
2026-09-29 12:17
🗑 Delete
📁 data_fusion/
-
0775
2026-09-29 12:17
🗑 Delete
📁 database_migration/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dataflow/
-
0775
2026-09-29 12:17
🗑 Delete
📁 datalineage/
-
0775
2026-09-29 12:17
🗑 Delete
📁 datapipelines/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dataplex/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dataproc/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dataproc_gdc/
-
0775
2026-09-29 12:17
🗑 Delete
📁 datastore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 datastream/
-
0775
2026-09-29 12:17
🗑 Delete
📁 deploy/
-
0775
2026-09-29 12:17
🗑 Delete
📁 deployment_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 design_center/
-
0775
2026-09-29 12:17
🗑 Delete
📁 developer_connect/
-
0775
2026-09-29 12:17
🗑 Delete
📁 developer_knowledge/
-
0775
2026-09-29 12:17
🗑 Delete
📁 device_run/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dialogflow/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dlp/
-
0775
2026-09-29 12:17
🗑 Delete
📁 dns/
-
0775
2026-09-29 12:17
🗑 Delete
📁 domains/
-
0775
2026-09-29 12:17
🗑 Delete
📁 edge_cache/
-
0775
2026-09-29 12:17
🗑 Delete
📁 edge_cloud/
-
0775
2026-09-29 12:17
🗑 Delete
📁 emulators/
-
0775
2026-09-29 12:17
🗑 Delete
📁 endpoints/
-
0775
2026-09-29 12:17
🗑 Delete
📁 error_reporting/
-
0775
2026-09-29 12:17
🗑 Delete
📁 essential_contacts/
-
0775
2026-09-29 12:17
🗑 Delete
📁 eventarc/
-
0775
2026-09-29 12:17
🗑 Delete
📁 fault_testing/
-
0775
2026-09-29 12:17
🗑 Delete
📁 filestore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 firebase/
-
0775
2026-09-29 12:17
🗑 Delete
📁 firebase_data_connect/
-
0775
2026-09-29 12:17
🗑 Delete
📁 firestore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 functions/
-
0775
2026-09-29 12:17
🗑 Delete
📁 gemini/
-
0775
2026-09-29 12:17
🗑 Delete
📁 genomics/
-
0775
2026-09-29 12:17
🗑 Delete
📁 healthcare/
-
0775
2026-09-29 12:17
🗑 Delete
📁 iam/
-
0775
2026-09-29 12:17
🗑 Delete
📁 iap/
-
0775
2026-09-29 12:17
🗑 Delete
📁 identity/
-
0775
2026-09-29 12:17
🗑 Delete
📁 ids/
-
0775
2026-09-29 12:17
🗑 Delete
📁 immersive_stream/
-
0775
2026-09-29 12:17
🗑 Delete
📁 infra_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 kms/
-
0775
2026-09-29 12:17
🗑 Delete
📁 logging/
-
0775
2026-09-29 12:17
🗑 Delete
📁 looker/
-
0775
2026-09-29 12:17
🗑 Delete
📁 lustre/
-
0775
2026-09-29 12:17
🗑 Delete
📁 managed_flink/
-
0775
2026-09-29 12:17
🗑 Delete
📁 managed_kafka/
-
0775
2026-09-29 12:17
🗑 Delete
📁 media/
-
0775
2026-09-29 12:17
🗑 Delete
📁 memcache/
-
0775
2026-09-29 12:17
🗑 Delete
📁 memorystore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 meta/
-
0775
2026-09-29 12:17
🗑 Delete
📁 metastore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 microservices/
-
0775
2026-09-29 12:17
🗑 Delete
📁 migration/
-
0775
2026-09-29 12:17
🗑 Delete
📁 ml/
-
0775
2026-09-29 12:17
🗑 Delete
📁 mldiagnostics/
-
0775
2026-09-29 12:17
🗑 Delete
📁 model_armor/
-
0775
2026-09-29 12:17
🗑 Delete
📁 monitoring/
-
0775
2026-09-29 12:17
🗑 Delete
📁 mps/
-
0775
2026-09-29 12:17
🗑 Delete
📁 netapp/
-
0775
2026-09-29 12:17
🗑 Delete
📁 network_connectivity/
-
0775
2026-09-29 12:17
🗑 Delete
📁 network_management/
-
0775
2026-09-29 12:17
🗑 Delete
📁 network_security/
-
0775
2026-09-29 12:17
🗑 Delete
📁 network_services/
-
0775
2026-09-29 12:17
🗑 Delete
📁 notebooks/
-
0775
2026-09-29 12:17
🗑 Delete
📁 number_registry/
-
0775
2026-09-29 12:17
🗑 Delete
📁 observability/
-
0775
2026-09-29 12:17
🗑 Delete
📁 onboarding/
-
0775
2026-09-29 12:17
🗑 Delete
📁 oracle_database/
-
0775
2026-09-29 12:17
🗑 Delete
📁 orchestration_pipelines/
-
0775
2026-09-29 12:17
🗑 Delete
📁 org_policies/
-
0775
2026-09-29 12:17
🗑 Delete
📁 organizations/
-
0775
2026-09-29 12:17
🗑 Delete
📁 orglifecycle/
-
0775
2026-09-29 12:17
🗑 Delete
📁 pam/
-
0775
2026-09-29 12:17
🗑 Delete
📁 parallelstore/
-
0775
2026-09-29 12:17
🗑 Delete
📁 parametermanager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 policy_intelligence/
-
0775
2026-09-29 12:17
🗑 Delete
📁 policy_troubleshoot/
-
0775
2026-09-29 12:17
🗑 Delete
📁 preview/
-
0775
2026-09-29 12:17
🗑 Delete
📁 privateca/
-
0775
2026-09-29 12:17
🗑 Delete
📁 projects/
-
0775
2026-09-29 12:17
🗑 Delete
📁 publicca/
-
0775
2026-09-29 12:17
🗑 Delete
📁 pubsub/
-
0775
2026-09-29 12:17
🗑 Delete
📁 quotas/
-
0775
2026-09-29 12:17
🗑 Delete
📁 recaptcha/
-
0775
2026-09-29 12:17
🗑 Delete
📁 recommender/
-
0775
2026-09-29 12:17
🗑 Delete
📁 redis/
-
0775
2026-09-29 12:17
🗑 Delete
📁 remote_build_execution/
-
0775
2026-09-29 12:17
🗑 Delete
📁 resource_config/
-
0775
2026-09-29 12:17
🗑 Delete
📁 resource_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 run/
-
0775
2026-09-29 12:17
🗑 Delete
📁 runtime_config/
-
0775
2026-09-29 12:17
🗑 Delete
📁 scc/
-
0775
2026-09-29 12:17
🗑 Delete
📁 scheduler/
-
0775
2026-09-29 12:17
🗑 Delete
📁 seclm/
-
0775
2026-09-29 12:17
🗑 Delete
📁 secrets/
-
0775
2026-09-29 12:17
🗑 Delete
📁 service_directory/
-
0775
2026-09-29 12:17
🗑 Delete
📁 service_extensions/
-
0775
2026-09-29 12:17
🗑 Delete
📁 service_health/
-
0775
2026-09-29 12:17
🗑 Delete
📁 services/
-
0775
2026-09-29 12:17
🗑 Delete
📁 software_delivery_trust/
-
0775
2026-09-29 12:17
🗑 Delete
📁 source/
-
0775
2026-09-29 12:17
🗑 Delete
📁 source_manager/
-
0775
2026-09-29 12:17
🗑 Delete
📁 spanner/
-
0775
2026-09-29 12:17
🗑 Delete
📁 spectrum_access/
-
0775
2026-09-29 12:17
🗑 Delete
📁 sql/
-
0775
2026-09-29 12:17
🗑 Delete
📁 storage/
-
0775
2026-09-29 12:17
🗑 Delete
📁 support/
-
0775
2026-09-29 12:17
🗑 Delete
📁 tasks/
-
0775
2026-09-29 12:17
🗑 Delete
📁 telco_automation/
-
0775
2026-09-29 12:17
🗑 Delete
📁 terraform/
-
0775
2026-09-29 12:17
🗑 Delete
📁 topic/
-
0775
2026-09-29 12:17
🗑 Delete
📁 trace/
-
0775
2026-09-29 12:17
🗑 Delete
📁 transcoder/
-
0775
2026-09-29 12:17
🗑 Delete
📁 transfer/
-
0775
2026-09-29 12:17
🗑 Delete
📁 vector_search/
-
0775
2026-09-29 12:17
🗑 Delete
📁 vmware/
-
0775
2026-09-29 12:17
🗑 Delete
📁 web_security_scanner/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workbench/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workflows/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workload_identity/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workspace_add_ons/
-
0775
2026-09-29 12:17
🗑 Delete
📁 workstations/
-
0775
2026-09-29 12:17
🗑 Delete
📁 zone_management/
-
0775
2026-09-29 12:17
🗑 Delete
__init__.py
7.5K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
cheat_sheet.py
5.9K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
docker.py
6.2K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
feedback.py
5.3K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
help.py
5K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
info.py
3.9K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
init.py
23.4K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
interactive.py
10.4K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
survey.py
3K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
unlock.py
2.1K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del
version.py
2.1K
0644
1980-01-01 08:00
👁 View
✏️ Edit
📝 Rename
📦 Move
🗑 Del