构建使用基础镜像
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

24 lines
493 B

#!/usr/bin/python
# -*- coding: utf-8 -*-
import docker
client = docker.DockerClient(base_url='unix://var/run/docker.sock')
def exist_images(name):
# image = client.images.get('hello-world')
try:
client.images.get(name)
return True
except docker.errors.ImageNotFound:
return False
except docker.errors.APIError as err:
print(err)
if __name__ == '__main__':
print(exist_images('alpine:3.15'))
print(exist_images('alpine:latest'))