Beispiel #1
0
#!/usr/bin/env python3
# coding=utf-8
import sys
import urllib.request
from utils import Fore, parse_image_arg, chunked_copy, clear_progress, handle_sigint, ensure_ca_load

# handle arguments

handle_sigint()
ensure_ca_load()

if len(sys.argv) < 2:
	print('usage: ./get-source.py image[:tag]')
	sys.exit(-1)

image, tag, fname, label = parse_image_arg(sys.argv[1], False)

dfurl = ''
tgurl = ''

# find the Dockerfile for the specified image and tag

print('%s[*]%s Fetching official-images info for %s%s%s:%s%s%s...' % (Fore.GREEN, Fore.RESET, Fore.YELLOW, image, Fore.RESET, Fore.YELLOW, tag, Fore.RESET))

try:
	with urllib.request.urlopen('https://raw.githubusercontent.com/docker-library/official-images/master/library/' + image) as f:

		data = f.read().decode('utf-8').splitlines() + ['']

		# there seems to be two versions for this file:
		#  a) simplistic one-line per tag:
import sys
import json
import time
import urllib.request
from utils import Fore, parse_image_arg, chunked_copy, clear_progress, handle_sigint, ensure_ca_load

# handle arguments

handle_sigint()
ensure_ca_load()

if len(sys.argv) < 2:
	print('usage: ./get-prebuilt.py image[:tag]')
	sys.exit(-1)

image, tag, fname, label = parse_image_arg(sys.argv[1], False)

fimage = image if '/' in image else 'library/' + image
token  = ''
expire = 0

# get auth token to Docker Hub

def request_auth_token():
	global token, expire, fimage

	print('%s[*]%s Requesting authorization token...' % (Fore.GREEN, Fore.RESET))

	try:
		with urllib.request.urlopen('https://auth.docker.io/token?service=registry.docker.io&scope=repository:%s:pull' % fimage) as f:
Beispiel #3
0
imgarg = ''
runhooks = True

if len(sys.argv) > 1:
    for arg in sys.argv[1:]:
        if arg.lower() == '--no-hooks':
            runhooks = False
        elif not imgarg:
            imgarg = arg

if not imgarg:
    print('usage: ./install.py [--no-hooks] image[:tag] | tarball | squashfs')
    print('\noptions:\n  --no-hooks    Omits running the hook scripts.')
    exit(-1)

image, tag, fname, label = parse_image_arg(imgarg, True)

# sanity checks

print('%s[*]%s Probing the Linux subsystem...' % (Fore.GREEN, Fore.RESET))

basedir, lxpath = probe_wsl()

user = ''
isroot = False
homedir = ''
homedirw = ''

# somewhat a major issue, stdout and stderr can't be redirected, so this script can't monitor the output
# of any of the launched commands. it can, however, receive the exit status, so that's something, I guess.
# ref: https://github.com/Microsoft/BashOnWindows/issues/2