directory search
Compose About 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 bundle docker-compose config docker-compose create docker-compose down docker-compose events docker-compose exec docker-compose help docker-compose images docker-compose kill docker-compose logs docker-compose pause docker-compose port docker-compose ps docker-compose pull docker-compose push docker-compose restart docker-compose rm docker-compose run docker-compose scale docker-compose start docker-compose stop docker-compose top docker-compose unpause docker-compose up Environment file (Compose) Environment variables in Compose Extend services in Compose Frequently asked questions (Compose) Getting started (Compose) Install Compose Link environment variables (deprecated) (Compose) Networking in Compose Overview of Docker Compose Overview of docker-compose CLI Quickstart: Compose and WordPress Rails and PostgreSQL (Compose) Sample apps with Compose Using Compose in production Using Compose with Swarm Engine .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-ng Best 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 network Delete the service (Engine) Deploy a service (Engine) Deploy services to a swarm (Engine) Deprecated Engine features Docker container networking (Engine) Docker overview (Engine) Docker run reference (Engine) Dockerfile reference (Engine) Dockerize an application Drain a node (Engine) Engine FAQ (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.10 Optional Linux post-installation steps (Engine) Overview (Engine) PostgreSQL (Engine) Raft consensus in swarm mode (Engine) Riak (Engine) Run Docker Engine in swarm mode Scale 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 Guide Amazon 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 mounts Troubleshoot 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: CLI Daemon CLI reference (dockerd) (Engine) docker docker attach docker build docker checkpoint docker checkpoint create docker checkpoint ls docker checkpoint rm docker commit docker config docker config create docker config inspect docker config ls docker config rm docker container docker container attach docker container commit docker container cp docker container create docker container diff docker container exec docker container export docker container inspect docker container kill docker container logs docker container ls docker container pause docker container port docker container prune docker container rename docker container restart docker container rm docker container run docker container start docker container stats docker container stop docker container top docker container unpause docker container update docker container wait docker cp docker create docker deploy docker diff docker events docker exec docker export docker history docker image docker image build docker image history docker image import docker image inspect docker image load docker image ls docker image prune docker image pull docker image push docker image rm docker image save docker image tag docker images docker import docker info docker inspect docker kill docker load docker login docker logout docker logs docker network docker network connect docker network create docker network disconnect docker network inspect docker network ls docker network prune docker network rm docker node docker node demote docker node inspect docker node ls docker node promote docker node ps docker node rm docker node update docker pause docker plugin docker plugin create docker plugin disable docker plugin enable docker plugin inspect docker plugin install docker plugin ls docker plugin push docker plugin rm docker plugin set docker plugin upgrade docker port docker ps docker pull docker push docker rename docker restart docker rm docker rmi docker run docker save docker search docker secret docker secret create docker secret inspect docker secret ls docker secret rm docker service docker service create docker service inspect docker service logs docker service ls docker service ps docker service rm docker service scale docker service update docker stack docker stack deploy docker stack ls docker stack ps docker stack rm docker stack services docker start docker stats docker stop docker swarm docker swarm ca docker swarm init docker swarm join docker swarm join-token docker swarm leave docker swarm unlock docker swarm unlock-key docker swarm update docker system docker system df docker system events docker system info docker system prune docker tag docker top docker unpause docker update docker version docker volume docker volume create docker volume inspect docker volume ls docker volume prune docker volume rm docker wait Use the Docker command line (Engine) Engine: Extend Access authorization plugin (Engine) Docker log driver plugins Docker network driver plugins (Engine) Extending Engine with plugins Managed plugin system (Engine) Plugin configuration (Engine) Plugins API (Engine) Volume plugins (Engine) Engine: Security AppArmor 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 Engine Use trusted images Using certificates for repository client verification (Engine) Engine: Tutorials Engine tutorials Network containers (Engine) Get Started Part 1: Orientation Part 2: Containers Part 3: Services Part 4: Swarms Part 5: Stacks Part 6: Deploy your app Machine Amazon Web Services (Machine) Digital Ocean (Machine) docker-machine active docker-machine config docker-machine create docker-machine env docker-machine help docker-machine inspect docker-machine ip docker-machine kill docker-machine ls docker-machine provision docker-machine regenerate-certs docker-machine restart docker-machine rm docker-machine scp docker-machine ssh docker-machine start docker-machine status docker-machine stop docker-machine upgrade docker-machine url Driver 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 Machine Machine Machine CLI overview Machine command-line completion Machine concepts and help Machine overview Microsoft Azure (Machine) Microsoft Hyper-V (Machine) Migrate from Boot2Docker to Machine OpenStack (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) Notary Client configuration (Notary) Common Server and signer configurations (Notary) Getting started with Notary Notary changelog Notary configuration files Running a Notary service Server configuration (Notary) Signer configuration (Notary) Understand the service architecture (Notary) Use the Notary client
characters

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中的内容信任

  • 管理内容信任的密钥

  • 内容信任的自动化

  • 在内容信任沙箱中播放

Previous article: Next article: