$ git clone https://github.com/SystemRage/py-kms.git
使用 CentOS 的 Dockerfile
FROM centos:centos7.6.1810
RUN yum -y install epel-release && \
yum -y install \
python36 python36-setuptools && \
yum clean all && \
rm -rf /var/cache/yum && \
easy_install-3.6 pip && \
pip3 install tzlocal && \
pip3 install pysqlite3 && \
rm -rf /root/.cache
ADD ./py-kms/py3-kms /app
WORKDIR /app
# Microsoft's KMS port
EXPOSE 1688
CMD ["python36", "server.py"]
可以使用 Python3 的 image,但實在太大了,有 900多MB。若使用 jfloff/alpine-python:3.6-slim 的 image,則可降到 100MB 以下,其 Dockerfile 如下FROM jfloff/alpine-python:3.6-slim
RUN pip3 install tzlocal && \
pip3 install pysqlite3 && \
rm -rf /root/.cache && \
touch /requirements.installed
ADD ./py-kms/py3-kms /app
WORKDIR /app
# Microsoft's KMS port
EXPOSE 1688
CMD ["python3", "server.py"]
docker-compose.yml 的內容
py-kms:
build: .
ports:
- 1688:1688
建立 image 及 執行$ docker-compose build
$ docker-compose up -d
# docker exec -it py-kms-server_py-kms_1 bash
[root@d5bc8bfc000f app]# python36 client.py localhost
Client generating RPC Bind Request...
Server receiving
Client sending RPC Bind Request... ===============>
Server sending
Client received RPC Bind Response !!! <===============
RPC Bind acknowledged !!!
Client generating Activation Request dictionary...
Client generating Activation Request data...
Client generating RPC Activation Request...
Server receiving
Client sending RPC Activation Request... ===============>
Server sending
Client received Response !!! <===============
Activation Done !!!
大概如此有人使用 python 的 image 來建立,但 size 太大了,各 image 大小比較
- jfloff/alpine-python:3.6-slim: 83.7MB
- CentOS7+Python36: 275MB
- CentOS7+Python36+git: 329MB
- Python3: 929MB
執行認證
slmgr -skms 172.16.16.15
slmgr -ato
測試看成不成功
沒有留言:
張貼留言