Skip to content

Commit 0dbe872

Browse files
author
Mihaela Blendea
committed
Add offline install script
1 parent d2f2834 commit 0dbe872

2 files changed

Lines changed: 125 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Push SQL Server big data cluster Docker images to your own private Docker repository
2+
3+
Big data clusters must have access to a Docker repository from which to pull container images. If you need to deploy to an environment that can't access the registry provided by Microsoft, you need to first push necessary images to your own private repository that the environment can access. This repository is then used as the target for a new deployment.
4+
5+
Using this sample Python script, you can pull all images from the Microsoft repository to your local Docker environment, and then push them to your own private repo.
6+
7+
## Prerequisites
8+
9+
- Docker Engine 1.8+ on any supported Linux distribution or Docker for Mac/Windows. For more information, see [Install Docker](https://docs.docker.com/engine/installation/).
10+
- Running the script will require: Python minimum version 3.0
11+
12+
## Instructions
13+
14+
Run the script using:
15+
```
16+
python push-bdc-images-to-custom-private-repo.py
17+
```
18+
19+
>**Note**
20+
>
21+
>If you have both python3 and python2 on your client machine and in the path, you will have to run the command using python3:
22+
>```
23+
>python3 push-bdc-images-to-custom-private-repo.py
24+
>```
25+
26+
When prompted, provide your input for:
27+
- Docker registry, repository and credentials to access Microsoft private registry where the images will be pulled from (source)
28+
- Docker registry, repository and credentials to access your private registry where the images will be pushed to (target)
29+
30+
## Deploy with from your private repository
31+
32+
To deploy from your private repository, use the steps described in the [deployment guide](deployment-guidance.md), but customize the following environment variables to match your private Docker repository.
33+
34+
- **DOCKER_REGISTRY**
35+
- **DOCKER_REPOSITORY**
36+
- **DOCKER_USERNAME**
37+
- **DOCKER_PASSWORD**
38+
- **DOCKER_EMAIL**
39+
- **DOCKER_IMAGE_TAG**
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# requires installation of Docker: https://docs.docker.com/install/
2+
3+
from subprocess import check_output, CalledProcessError, STDOUT, Popen, PIPE
4+
import os
5+
import getpass
6+
7+
def execute_cmd (cmd):
8+
if os.name=="nt":
9+
process = Popen(cmd.split(),stdin=PIPE, shell=True)
10+
else:
11+
process = Popen(cmd.split(),stdin=PIPE)
12+
stdout, stderr = process.communicate()
13+
if (stderr is not None):
14+
raise Exception(stderr)
15+
16+
SOURCE_DOCKER_REGISTRY = input("Provide Docker registry source - press ENTER for using `private-repo.microsoft.com`:") or "private-repo.microsoft.com"
17+
SOURCE_DOCKER_REPOSITORY = input("Provide Docker repository source - press ENTER for using `mssql-private-preview`:") or "mssql-private-preview"
18+
SOURCE_DOCKER_USERNAME = input("Provide Docker username for the source registry:")
19+
SOURCE_DOCKER_PASSWORD=getpass.getpass("Provide Docker password for the source registry:")
20+
SOURCE_DOCKER_TAG = input("Provide Docker tag for the images at the source: ") or "latest"
21+
22+
TARGET_DOCKER_REGISTRY = input("Provide Docker registry target:")
23+
TARGET_DOCKER_REPOSITORY = input("Provide Docker repository target:")
24+
TARGET_DOCKER_USERNAME = input("Provide Docker username for the target registry:")
25+
TARGET_DOCKER_PASSWORD = getpass.getpass("Provide Docker password for the target registry:")
26+
TARGET_DOCKER_TAG = input("Provide Docker tag for the images at the target: ") or "latest"
27+
28+
images = [ 'mssql-appdeploy-init',
29+
'mssql-monitor-fluentbit',
30+
'mssql-monitor-collectd',
31+
'mssql-server-data',
32+
'mssql-hadoop',
33+
'mssql-java',
34+
'mssql-mlservices-pythonserver',
35+
'mssql-mlservices-rserver',
36+
'mssql-monitor-elasticsearch',
37+
'mssql-monitor-influxdb',
38+
'mssql-security-knox',
39+
'mssql-mlserver-r-runtime',
40+
'mssql-mlserver-py-runtime',
41+
'mssql-controller',
42+
'mssql-portal',
43+
'mssql-server-controller',
44+
'mssql-monitor-grafana',
45+
'mssql-monitor-kibana',
46+
'mssql-service-proxy',
47+
'mssql-app-service-proxy',
48+
'mssql-ssis-app-runtime',
49+
'mssql-monitor-telegraf']
50+
51+
print("Execute docker login to source registry: " + SOURCE_DOCKER_REGISTRY)
52+
cmd = "docker login " + SOURCE_DOCKER_REGISTRY + " -u " + SOURCE_DOCKER_USERNAME + " -p " + SOURCE_DOCKER_PASSWORD
53+
execute_cmd(cmd)
54+
print("")
55+
56+
57+
print("Pulling images from source repository: " + SOURCE_DOCKER_REGISTRY + "/" + SOURCE_DOCKER_REPOSITORY)
58+
cmd = ""
59+
for image in images:
60+
cmd += "docker pull " + SOURCE_DOCKER_REGISTRY + "/" + SOURCE_DOCKER_REPOSITORY + "/" + image + ":" + SOURCE_DOCKER_TAG + " & "
61+
cmd = cmd[:len(cmd)-3]
62+
execute_cmd(cmd)
63+
64+
print("Execute docker login to target registry:" + TARGET_DOCKER_REGISTRY)
65+
cmd = "docker login " + TARGET_DOCKER_REGISTRY + " -u " + TARGET_DOCKER_USERNAME + " -p " + TARGET_DOCKER_PASSWORD
66+
execute_cmd(cmd)
67+
print("")
68+
69+
print("Tagging local images...")
70+
cmd = ""
71+
for image in images:
72+
cmd += "docker tag " + SOURCE_DOCKER_REGISTRY + "/" + SOURCE_DOCKER_REPOSITORY + "/" + image + ":" + SOURCE_DOCKER_TAG + " " + TARGET_DOCKER_REGISTRY + "/" + TARGET_DOCKER_REPOSITORY + "/" + image + ":" + TARGET_DOCKER_TAG + " & "
73+
cmd = cmd[:len(cmd)-3]
74+
execute_cmd(cmd)
75+
76+
print("Push images to target Docker repository: " + TARGET_DOCKER_REGISTRY + "/" + TARGET_DOCKER_REPOSITORY)
77+
cmd = ""
78+
for image in images:
79+
cmd += "docker push " + TARGET_DOCKER_REGISTRY + "/" + TARGET_DOCKER_REPOSITORY + "/" + image + ":" + TARGET_DOCKER_TAG + " & "
80+
cmd = cmd[:len(cmd)-3]
81+
execute_cmd(cmd)
82+
83+
print("Images are now pushed to the target repository.")
84+
cmd = "docker images"
85+
execute_cmd(cmd)
86+

0 commit comments

Comments
 (0)