How to validate the authenticity of docker base images?

白昼怎懂夜的黑 提交于 2020-08-05 06:34:12

问题


How we can make sure that the docker base image for example ubuntu:latest are not corrupted?? That is how to check the authenticity of docker base images??


回答1:


Checksum verification

docker pull verifies download of its each layer using Checksum. It will detect corrupted download.

$ docker pull ubuntu:latest 
latest: Pulling from library/ubuntu
1be7f2b886e8: Downloading [=====>                                             ]  4.865MB/42.86MB
6fbc4a21b806: Download complete 
c71a6f8e1378: Download complete 
4be3072e5a37: Verifying Checksum  <<-- It verifies Checksum 
06c6d2f59700: Download complete

So, you do not need to check where your pulled image is corrupted or not

Content trust in Docker

Content trust provides the ability to use digital signatures for data sent to and received from remote Docker registries. These signatures allow client-side verification of the integrity and publisher of specific image tags.

When you enable content trust, signing occurs on the client after push and verification happens on the client after pull

$ export DOCKER_CONTENT_TRUST=1; docker pull ubuntu:latest

Pull (1 of 1): ubuntu:latest@sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e60f388875e5b7d9b2b696
sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e60f388875e5b7d9b2b696: Pulling from library/ubuntu
Digest: sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e60f388875e5b7d9b2b696
Status: Image is up to date for ubuntu@sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e60f388875e5b7d9b2b696
Tagging ubuntu@sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e60f388875e5b7d9b2b696 as ubuntu:latest

Read more about content_trust




回答2:


Enable docker content trust then it pulls only trusted images from Docker registry. That is only signed images are pulled from the registry. Before enabling it Docker pulls un-trusted images also.

export DOCKER_CONTENT_TRUST=1

In Docker hub also check Docker Security Scan results of the image you want to pull and use the image that doesn't have any security vulnerabilities in the scan results. The below link will give more information about it. https://docs.docker.com/docker-hub/official_repos/#should-i-use-official-repositories




回答3:


You can check official images in Docker Hub and with docker search command

docker@default:~$ docker search ubuntu
NAME                                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
ubuntu                                                 Ubuntu is a Debian-based Linux operating s...   7175                [OK]

Mode details in docker docs and docker github



来源:https://stackoverflow.com/questions/48545928/how-to-validate-the-authenticity-of-docker-base-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!