目录搜索
ComposeAbout versions and upgrading (Compose)ASP.NET Core + SQL Server on Linux (Compose)CLI environment variables (Compose)Command-line completion (Compose)Compose(组成)Compose command-line reference(组合命令行参考)Control startup order (Compose)Django and PostgreSQL (Compose)Docker stacks and distributed application bundles (Compose)docker-compose build(docker-compose构建)docker-compose bundledocker-compose configdocker-compose createdocker-compose downdocker-compose eventsdocker-compose execdocker-compose helpdocker-compose imagesdocker-compose killdocker-compose logsdocker-compose pausedocker-compose portdocker-compose psdocker-compose pulldocker-compose pushdocker-compose restartdocker-compose rmdocker-compose rundocker-compose scaledocker-compose startdocker-compose stopdocker-compose topdocker-compose unpausedocker-compose upEnvironment file (Compose)Environment variables in ComposeExtend services in ComposeFrequently asked questions (Compose)Getting started (Compose)Install ComposeLink environment variables (deprecated) (Compose)Networking in ComposeOverview of Docker ComposeOverview of docker-compose CLIQuickstart: Compose and WordPressRails and PostgreSQL (Compose)Sample apps with ComposeUsing Compose in productionUsing Compose with SwarmEngine.NET Core application (Engine)About images, containers, and storage drivers (Engine)Add nodes to the swarm (Engine)Apply custom metadata (Engine)Apply rolling updates (Engine)apt-cacher-ngBest practices for writing Dockerfiles (Engine)Binaries (Engine)Bind container ports to the host (Engine)Breaking changes (Engine)Build your own bridge (Engine)Configure container DNS (Engine)Configure container DNS in user-defined networks (Engine)CouchDB (Engine)Create a base image (Engine)Create a swarm (Engine)Customize the docker0 bridge (Engine)Debian (Engine)Default bridge networkDelete the service (Engine)Deploy a service (Engine)Deploy services to a swarm (Engine)Deprecated Engine featuresDocker container networking (Engine)Docker overview (Engine)Docker run reference (Engine)Dockerfile reference (Engine)Dockerize an applicationDrain a node (Engine)EngineFAQ (Engine)Fedora (Engine)Get started (Engine)Get started with macvlan network driver (Engine)Get started with multi-host networking (Engine)How nodes work (Engine)How services work (Engine)Image management (Engine)Inspect the service (Engine)Install Docker (Engine)IPv6 with Docker (Engine)Join nodes to a swarm (Engine)Legacy container links (Engine)Lock your swarm (Engine)Manage nodes in a swarm (Engine)Manage sensitive data with Docker secrets (Engine)Manage swarm security with PKI (Engine)Manage swarm service networks (Engine)Migrate to Engine 1.10Optional Linux post-installation steps (Engine)Overview (Engine)PostgreSQL (Engine)Raft consensus in swarm mode (Engine)Riak (Engine)Run Docker Engine in swarm modeScale the service (Engine)SDKs (Engine)Select a storage driver (Engine)Set up for the tutorial (Engine)SSHd (Engine)Storage driver overview (Engine)Store service configuration data (Engine)Swarm administration guide (Engine)Swarm mode key concepts (Engine)Swarm mode overlay network security model (Engine)Swarm mode overview (Engine)Understand container communication (Engine)Use multi-stage builds (Engine)Use swarm mode routing mesh (Engine)Use the AUFS storage driver (Engine)Use the Btrfs storage driver (Engine)Use the Device mapper storage driver (Engine)Use the OverlayFS storage driver (Engine)Use the VFS storage driver (Engine)Use the ZFS storage driver (Engine)Engine: Admin GuideAmazon CloudWatch logs logging driver (Engine)Bind mounts (Engine)Collect Docker metrics with Prometheus (Engine)Configuring and running Docker (Engine)Configuring logging drivers (Engine)Control and configure Docker with systemd (Engine)ETW logging driver (Engine)Fluentd logging driver (Engine)Format command and log output (Engine)Google Cloud logging driver (Engine)Graylog Extended Format (GELF) logging driver (Engine)Journald logging driver (Engine)JSON File logging driver (Engine)Keep containers alive during daemon downtime (Engine)Limit a container's resources (Engine)Link via an ambassador container (Engine)Log tags for logging driver (Engine)Logentries logging driver (Engine)PowerShell DSC usage (Engine)Prune unused Docker objects (Engine)Run multiple services in a container (Engine)Runtime metrics (Engine)Splunk logging driver (Engine)Start containers automatically (Engine)Storage overview (Engine)Syslog logging driver (Engine)tmpfs mountsTroubleshoot volume problems (Engine)Use a logging driver plugin (Engine)Using Ansible (Engine)Using Chef (Engine)Using Puppet (Engine)View a container's logs (Engine)Volumes (Engine)Engine: CLIDaemon CLI reference (dockerd) (Engine)dockerdocker attachdocker builddocker checkpointdocker checkpoint createdocker checkpoint lsdocker checkpoint rmdocker commitdocker configdocker config createdocker config inspectdocker config lsdocker config rmdocker containerdocker container attachdocker container commitdocker container cpdocker container createdocker container diffdocker container execdocker container exportdocker container inspectdocker container killdocker container logsdocker container lsdocker container pausedocker container portdocker container prunedocker container renamedocker container restartdocker container rmdocker container rundocker container startdocker container statsdocker container stopdocker container topdocker container unpausedocker container updatedocker container waitdocker cpdocker createdocker deploydocker diffdocker eventsdocker execdocker exportdocker historydocker imagedocker image builddocker image historydocker image importdocker image inspectdocker image loaddocker image lsdocker image prunedocker image pulldocker image pushdocker image rmdocker image savedocker image tagdocker imagesdocker importdocker infodocker inspectdocker killdocker loaddocker logindocker logoutdocker logsdocker networkdocker network connectdocker network createdocker network disconnectdocker network inspectdocker network lsdocker network prunedocker network rmdocker nodedocker node demotedocker node inspectdocker node lsdocker node promotedocker node psdocker node rmdocker node updatedocker pausedocker plugindocker plugin createdocker plugin disabledocker plugin enabledocker plugin inspectdocker plugin installdocker plugin lsdocker plugin pushdocker plugin rmdocker plugin setdocker plugin upgradedocker portdocker psdocker pulldocker pushdocker renamedocker restartdocker rmdocker rmidocker rundocker savedocker searchdocker secretdocker secret createdocker secret inspectdocker secret lsdocker secret rmdocker servicedocker service createdocker service inspectdocker service logsdocker service lsdocker service psdocker service rmdocker service scaledocker service updatedocker stackdocker stack deploydocker stack lsdocker stack psdocker stack rmdocker stack servicesdocker startdocker statsdocker stopdocker swarmdocker swarm cadocker swarm initdocker swarm joindocker swarm join-tokendocker swarm leavedocker swarm unlockdocker swarm unlock-keydocker swarm updatedocker systemdocker system dfdocker system eventsdocker system infodocker system prunedocker tagdocker topdocker unpausedocker updatedocker versiondocker volumedocker volume createdocker volume inspectdocker volume lsdocker volume prunedocker volume rmdocker waitUse the Docker command line (Engine)Engine: ExtendAccess authorization plugin (Engine)Docker log driver pluginsDocker network driver plugins (Engine)Extending Engine with pluginsManaged plugin system (Engine)Plugin configuration (Engine)Plugins API (Engine)Volume plugins (Engine)Engine: SecurityAppArmor security profiles for Docker (Engine)Automation with content trust (Engine)Content trust in Docker (Engine)Delegations for content trust (Engine)Deploying Notary (Engine)Docker security (Engine)Docker security non-events (Engine)Isolate containers with a user namespace (Engine)Manage keys for content trust (Engine)Play in a content trust sandbox (Engine)Protect the Docker daemon socket (Engine)Seccomp security profiles for Docker (Engine)Secure EngineUse trusted imagesUsing certificates for repository client verification (Engine)Engine: TutorialsEngine tutorialsNetwork containers (Engine)Get StartedPart 1: OrientationPart 2: ContainersPart 3: ServicesPart 4: SwarmsPart 5: StacksPart 6: Deploy your appMachineAmazon Web Services (Machine)Digital Ocean (Machine)docker-machine activedocker-machine configdocker-machine createdocker-machine envdocker-machine helpdocker-machine inspectdocker-machine ipdocker-machine killdocker-machine lsdocker-machine provisiondocker-machine regenerate-certsdocker-machine restartdocker-machine rmdocker-machine scpdocker-machine sshdocker-machine startdocker-machine statusdocker-machine stopdocker-machine upgradedocker-machine urlDriver options and operating system defaults (Machine)Drivers overview (Machine)Exoscale (Machine)Generic (Machine)Get started with a local VM (Machine)Google Compute Engine (Machine)IBM Softlayer (Machine)Install MachineMachineMachine CLI overviewMachine command-line completionMachine concepts and helpMachine overviewMicrosoft Azure (Machine)Microsoft Hyper-V (Machine)Migrate from Boot2Docker to MachineOpenStack (Machine)Oracle VirtualBox (Machine)Provision AWS EC2 instances (Machine)Provision Digital Ocean Droplets (Machine)Provision hosts in the cloud (Machine)Rackspace (Machine)VMware Fusion (Machine)VMware vCloud Air (Machine)VMware vSphere (Machine)NotaryClient configuration (Notary)Common Server and signer configurations (Notary)Getting started with NotaryNotary changelogNotary configuration filesRunning a Notary serviceServer configuration (Notary)Signer configuration (Notary)Understand the service architecture (Notary)Use the Notary client
文字

Docker引擎支持将targets/releases委派用作可信图像标记的标准来源。

使用此委托可让您与其他发布者协作,而不共享您的存储库密钥,这是您的目标和快照密钥的组合。有关更多信息,请参阅管理内容信任的密钥)。合作者可以保留自己的授权密钥。

targets/releases委托当前是一项可选功能 - 为了设置委派,您必须使用公证CLI:

  1. 下载客户端并确保它在您的路径上可用

  1. ~/.notary/config.json使用以下内容创建配置文件:

{    "trust_dir" : "~/.docker/trust",    "remote_server": {      "url": "https://notary.docker.io"    }  }

这告诉公证Docker内容信任数据的存储位置,以及在Docker Hub中使用用于图像的公证服务器。

有关如何在默认Docker Content Trust用例外使用公证的更多详细信息,请参阅公证CLI文档。

请注意,使用公证客户端发布和列出委托更改时,您的Docker Hub凭据是必需的。

生成授权密钥

您的协作者需要生成私钥(RSA或ECDSA)并为您提供公钥,以便将其添加到targets/releases委派中。

他们生成这些密钥的最简单方法是使用OpenSSL。以下是如何生成2048位RSA部分密钥的示例(所有RSA密钥必须至少为2048位):

$ openssl genrsa -out delegation.key 2048Generating RSA private key, 2048 bit long modulus....................................................+++............+++e is 65537 (0x10001)

他们应该保持delegation.key私密 - 这是他们将用于签署标签的内容。

然后他们需要生成一个包含公钥的x509证书,这是他们会给你的。这是生成CSR(证书签名请求)的命令:

$ openssl req -new -sha256 -key delegation.key -out delegation.csr

然后他们可以将它发送给您信任的任何CA来签署证书,或者他们可以自行签署证书(在本示例中,创建有效期为1年的证书):

$ openssl x509 -req -sha256 -days 365 -in delegation.csr -signkey delegation.key -out delegation.crt

然后他们需要给你delegation.crt,无论是自签名还是由CA签署。

将授权密钥添加到现有存储库

如果您的存储库是使用1.11之前的Docker Engine版本创建的,那么在添加任何代理之前,应该将快照密钥轮换到服务器,以便协作者不需要您的快照密钥来签署和发布代码:

$ notary key rotate docker.io/<username>/<imagename> snapshot -r

这会告诉公证员为您的特定图像存储库轮换一个密钥 - 请注意,您必须包含docker.io/前缀。snapshot -r指定要特别旋转快照键,并且希望服务器对其进行管理(-r代表“远程”)。

在添加委派时,您必须使用您希望委派给协作者的公钥来获取PEM编码的x509证书。

假设您有证书delegation.crt,您可以为该用户添加一个委派,然后发布委派更改:

$ notary delegation add docker.io/<username>/<imagename> targets/releases delegation.crt --all-paths
$ notary publish docker.io/<username>/<imagename>

前面的示例说明了将委派添加targets/releases到图像存储库的请求(如果它不存在)。请务必使用targets/releases- 公证员支持多个委派角色,因此如果您错误地输入委派名称,公证人CLI将不会出错。但是,Docker引擎仅支持从中读取targets/releases

它还将协作者的公钥添加到委托中,targets/releases只要他们拥有与此公钥对应的私钥,就可以对委派进行签名。该--all-paths标志告诉公证员不要限制可以登录的标签名称targets/releases,这是我们强烈建议的targets/releases

发布更改会告诉服务器关于targets/releases委派的更改。

发布后,查看委派信息以确保您正确地将密钥添加到targets/releases

$ notary delegation list docker.io/<username>/<imagename>

      ROLE               PATHS                                   KEY IDS                                THRESHOLD
      ---------------------------------------------------------------------------------------------------------------
      targets/releases   "" <all paths>  729c7094a8210fd1e780e7b17b7bb55c9a28a48b871b07f65d97baf93898523a   1

你可以看到targets/releases它的路径和刚刚添加的密钥ID。

公证人目前不会将协作者名称映射到密钥,因此我们建议您一次添加并列出一个委托密钥,并在需要删除协作者时自己将密钥ID映射到协作者。

从现有存储库中删除委派密钥

要撤消协作者为图片存储库签署标签的功能,您需要从targets/releases代表团中删除其密钥。要做到这一点,你需要他们的钥匙的ID。

$ notary delegation remove docker.io/<username>/<imagename> targets/releases 729c7094a8210fd1e780e7b17b7bb55c9a28a48b871b07f65d97baf93898523a

Removal of delegation role targets/releases with keys [729c7094a8210fd1e780e7b17b7bb55c9a28a48b871b07f65d97baf93898523a], to repository "docker.io/<username>/<imagename>" staged for next publish.

撤销将在您发布后立即生效:

$ notary publish docker.io/<username>/<imagename>

请注意,通过删除targets/releases委派中的所有关键字,委派(以及任何登录到它的标记)都将被删除。这意味着这些标签将全部被删除,并且您最终可能会使用由目标键直接签名的较旧的旧版标签。

完全从存储库中删除委派targets/releases

如果您确定代表团不适合您,您可以targets/releases完全删除代表团。targets/releases但是,这也会删除当前所有的标签,并且最终可能会使用由目标键直接签名的较旧的旧标签。

要删除targets/releases委派:

$ notary delegation remove docker.io/<username>/<imagename> targets/releases

Are you sure you want to remove all data for this delegation? (yes/no)yes

Forced removal (including all keys and paths) of delegation role targets/releases to repository "docker.io/<username>/<imagename>" staged for next publish.$ notary publish docker.io/<username>/<imagename>

推动可信数据成为合作者

作为已添加到存储库targets/releases委派中的私钥的协作者,您需要将您生成的私钥导入到Content Trust中。

为此,您可以运行:

$ notary key import delegation.key --role user

delegation.key包含您的PEM编码私钥的文件在哪里?

完成之后docker push,在targets/releases代理中运行的包含密钥的任何存储库都将使用此导入的密钥自动对标签进行签名。

docker push 行为

docker push使用Docker Content Trust 运行时,如果Docker Engine存在,它将尝试签署并推送该代码targets/releases。如果没有,则如果密钥可用,则使用目标密钥来签署标签。

docker pulldocker build行为

在运行Docker Content Trust docker pulldocker buildDocker Content Trust时,Docker Engine将只提取由targets/releases代理角色签名的标签或直接用targets密钥签名的旧版代码。

相关信息

  • Docker中的内容信任

  • 管理内容信任的密钥

  • 内容信任的自动化

  • 在内容信任沙箱中播放

上一篇:下一篇: