Home
%3CLINGO-SUB%20id%3D%22lingo-sub-385970%22%20slang%3D%22en-US%22%3EDockerizing%20R%20and%20Python%20Web%20Services%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-385970%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20MSDN%20on%20Jul%2026%2C%202018%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20Containerization%20is%20an%20approach%20to%20software%20development%20in%20which%20an%20application%20or%20service%2C%20its%20dependencies%2C%20and%20its%20configuration%20(abstracted%20as%20deployment%20manifest%20files)%20are%20packaged%20together%20as%20a%20container%20image.%20The%20containerized%20application%20can%20be%20tested%20as%20a%20unit%20and%20deployed%20as%20a%20container%20image%20instance%20to%20the%20host%20operating%20system%20(OS).%20%3CA%20href%3D%22https%3A%2F%2Fwww.docker.com%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDocker%20%3C%2FA%3E%20is%20an%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdocker%2Fdocker%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20open-source%20project%20%3C%2FA%3E%20for%20automating%20the%20deployment%20of%20applications%20as%20portable%2C%20self-sufficient%20containers%20that%20can%20run%20on%20the%20cloud%20or%20on-premises.%20More%20information%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fstandard%2Fmicroservices-architecture%2Fcontainer-docker-introduction%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20here.%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98887iF15D6A82429AF40F%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmachine-learning-server%2Fwhat-is-machine-learning-server%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EMicrosoft%20Machine%20Learning%20Server%20%3C%2FA%3E%20is%20your%20flexible%20enterprise%20platform%20for%20analyzing%20data%20at%20scale%2C%20building%20intelligent%20apps%2C%20and%20discovering%20valuable%20insights%20across%20your%20business%20with%20full%20support%20for%20Python%20and%20R.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmachine-learning-server%2Fwhat-is-operationalization%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Operationalization%20%3C%2FA%3E%20refers%20to%20the%20process%20of%20deploying%20R%20and%20Python%20models%20and%20code%20to%20Machine%20Learning%20Server%20in%20the%20form%20of%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmachine-learning-server%2Foperationalize%2Fconcept-what-are-web-services%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20web%20services%20%3C%2FA%3E%20and%20the%20subsequent%20consumption%20of%20these%20services%20within%20client%20applications%20to%20affect%20business%20results.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20In%20this%20article%2C%20We%20will%20look%20into%20how%20to%20build%20a%20docker%20image%20containing%20%3CA%20href%3D%22https%3A%2F%2Fblogs.technet.microsoft.com%2Fmachinelearning%2F2018%2F02%2F27%2Fintroducing-the-microsoft-machine-learning-server-9-3-release%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Machine%20Learning%20Server%209.3%20%3C%2FA%3E%20using%20Dockerfiles%20and%20how-to-perform%20the%20following%20operations%20using%20the%20docker%20image%20%3A%20%3CBR%20%2F%3E%3COL%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3E%20Run%20R%20Shell%20%3C%2FSTRONG%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3E%20Run%20Python%20Shell%20%3C%2FSTRONG%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3E%20Run%20Jupyter%20Notebook%20%3C%2FSTRONG%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3E%20Run%20Onebox%20Configuration%20%3C%2FSTRONG%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3E%20Run%20R%20Web%20Service%20%3C%2FSTRONG%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3E%20Run%20Python%20Web%20Service%20%3C%2FSTRONG%3E%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FOL%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3EPrerequisites%20%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20Any%20Linux%20VM%20with%20docker%20community%20edition%20installed.%20For%20this%20article%2C%20I%20have%20spinned%20a%20%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%2F%23create%2FCanonical.UbuntuServer1604LTS-ARM%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Ubuntu%2016.04%20VM%20%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.docker.com%2Finstall%2Flinux%2Fdocker-ce%2Fubuntu%2F%23install-docker-ce%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20installed%20docker%20CE.%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3EStep%200%20%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20First%20let%20us%20create%20an%20image%20called%20%22mlserver%22%20with%20%3CA%20href%3D%22https%3A%2F%2Fblogs.technet.microsoft.com%2Fmachinelearning%2F2018%2F02%2F27%2Fintroducing-the-microsoft-machine-learning-server-9-3-release%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Machine%20Learning%20Server%209.3%20%3C%2FA%3E%20installed%20using%20the%20following%20Dockerfile%20%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Use%20%3CA%20href%3D%22https%3A%2F%2Fdocs.docker.com%2Fengine%2Freference%2Fcommandline%2Fbuild%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20docker%20build%20%3C%2FA%3E%20command%20to%20build%20image%20%22mlserver%22%20using%20the%20above%20dockerfile%20%3A%20%3CBR%20%2F%3E%20docker%20build%20-f%20mlserver-dockerfile%20-t%20mlserver%20.%20%3CBR%20%2F%3E%20Check%20if%20image%20%22mlserver%22%20is%20built%20successfully%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20images%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId-1484242785%22%20id%3D%22toc-hId-1508249501%22%3E%3CSTRONG%3E%20Run%20R%20Shell%20%3C%2FSTRONG%3E%3C%2FH3%3E%3CBR%20%2F%3E%20docker%20run%20-it%20mlserver%20R%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98888i8590976A3719787D%22%20%2F%3E%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId--1067914176%22%20id%3D%22toc-hId--1043907460%22%3E%3CSTRONG%3E%20Run%20Python%20Shell%20%3A%20%3C%2FSTRONG%3E%3C%2FH3%3E%3CBR%20%2F%3E%20docker%20run%20-it%20mlserver%20mlserver-python%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98889i067E6879FCD8484A%22%20%2F%3E%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId-674896159%22%20id%3D%22toc-hId-698902875%22%3E%3CSTRONG%3E%20Run%20Jupyter%20Notebook%20%3A%20%3C%2FSTRONG%3E%3C%2FH3%3E%3CBR%20%2F%3E%20docker%20run%20-p%208888%3A8888%20-it%20mlserver%20%2Fopt%2Fmicrosoft%2Fmlserver%2F9.3.0%2Fruntime%2Fpython%2Fbin%2Fjupyter%20notebook%20--no-browser%20--port%3D8888%20--ip%3D0.0.0.0%20--allow-root%20%3CBR%20%2F%3E%20Running%20the%20above%20command%20gives%20a%20link%20that%20you%20can%20open%20in%20your%20browser%20to%20use%20Jupyter%20Notebooks.%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98890i044E1B37CC167753%22%20%2F%3E%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId--1877260802%22%20id%3D%22toc-hId--1853254086%22%3E%3CSTRONG%3E%20Run%20One-box%20Configuration%20%3A%20%3C%2FSTRONG%3E%3C%2FH3%3E%3CBR%20%2F%3E%20You%20can%20configure%20Microsoft%20Learning%20Server%20after%20installation%20to%20act%20as%20a%20deployment%20server%20and%20to%20host%20analytic%20web%20services%20for%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmachine-learning-server%2Foperationalize%2Fconfigure-machine-learning-server-one-box%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20operationalization%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Build%20image%20%22mlserver-onebox%22%20using%20the%20above%20dockerfile%20%3A%20%3CBR%20%2F%3E%20docker%20build%20-f%20mlserver-onebox-dockerfile%20-t%20mlserver-onebox%20.%20%3CBR%20%2F%3E%20Check%20if%20image%20%22mlserver-onebox%22%20is%20built%20successfully%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20images%20%3CBR%20%2F%3E%20Start%20a%20onebox%20container%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20run%20--name%20mlserver-onebox-container%20-dit%20mlserver-onebox%20%3CBR%20%2F%3E%20Check%20the%20status%20of%20container%20using%20%3A%20%3CBR%20%2F%3E%20docker%20logs%20mlserver-onebox-container%20%3CBR%20%2F%3E%20Once%20you%20have%20confirmed%20that%20the%20diagnostic%20tests%20have%20passed%20successfully%20from%20the%20above%20command%2C%20you%20can%20start%20using%20it%20as%20one-box.%20(docker%20logs%20output%20should%20contain%20the%20following%20string%20%3A%20%22All%20Diagnostic%20Tests%20have%20passed.%22)%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Obtain%20the%20IP%20address%20of%20the%20container%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20inspect%20-f%20'%7B%7Brange%20.NetworkSettings.Networks%7D%7D%7B%7B.IPAddress%7D%7D%7B%7Bend%7D%7D'%20mlserver-onebox-container%20%3CBR%20%2F%3E%20'172.17.0.3'%20%3CBR%20%2F%3E%20and%20use%20it%20like%20a%20one-box%20%3A%20%3CBR%20%2F%3E%20az%20login%20--mls%20--mls-endpoint%20%22%3CA%20href%3D%22http%3A%2F%2F172.17.0.3%3A12800%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F172.17.0.3%3A12800%3C%2FA%3E%22%20--username%20%22admin%22%20--password%20%22Microsoft%402018%22%20%3CBR%20%2F%3E%20az%20ml%20admin%20diagnostic%20run%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId--134450467%22%20id%3D%22toc-hId--110443751%22%3E%3CSTRONG%3E%20Run%20R%20Web%20Service%20%3A%20%3C%2FSTRONG%3E%3C%2FH3%3E%3CBR%20%2F%3E%20We%20can%20also%20develop%20an%20image%20with%20a%20webservice%20pre-configured%20so%20that%20it%20is%20ready%20for%20consumption%20as%20soon%20as%20we%20spin%20a%20container.%20Here%20is%20an%20example%20to%20build%20an%20image%20with%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmachine-learning-server%2Foperationalize%2Fhow-to-deploy-web-service-publish-manage-in-r%231-r-code-and-model-are-objects%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Manual%20Transmission%20R%20Web%20Service%20%3C%2FA%3E%20pre-configured%20inside%20the%20image.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Build%20image%20%22rmanualtransmission%22%20using%20the%20above%20dockerfile%20%3A%20%3CBR%20%2F%3E%20docker%20build%20-f%20r-manualtransmission-dockerfile%20-t%20rmanualtransmission%20.%20%3CBR%20%2F%3E%20Check%20if%20image%20%22rmanualtransmission%22%20is%20built%20successfully%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20images%20%3CBR%20%2F%3E%20Start%20container%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20run%20--name%20rmanualtransmission-container%20-dit%20rmanualtransmission%20%3CBR%20%2F%3E%20Check%20the%20status%20of%20container%20using%20%3A%20%3CBR%20%2F%3E%20docker%20logs%20rmanualtransmission-container%20%3CBR%20%2F%3E%20Once%20you%20have%20confirmed%20that%20the%20diagnostic%20tests%20have%20passed%20successfully%20and%20web%20service%20has%20been%20published%2C%20you%20can%20start%20consuming%20the%20web%20service.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Obtain%20the%20IP%20address%20of%20the%20container%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20inspect%20-f%20'%7B%7Brange%20.NetworkSettings.Networks%7D%7D%7B%7B.IPAddress%7D%7D%7B%7Bend%7D%7D'%20rmanualtransmission-container%20%3CBR%20%2F%3E%20'172.17.0.3'%20%3CBR%20%2F%3E%20you%20can%20consume%20(or)%20obtain%20the%20swagger.json%20of%20ManualTranmission%20R%20Web%20Service%20using%20curl%20commands%20%3A%20%3CBR%20%2F%3E%20apt-get%20-y%20install%20jq%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20curl%20-s%20--header%20%22Content-Type%3A%20application%2Fjson%22%20--request%20POST%20--data%20'%7B%22username%22%3A%22admin%22%2C%22password%22%3A%22Microsoft%402018%22%7D'%20%3CA%20href%3D%22http%3A%2F%2F172.17.0.3%3A12800%2Flogin%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F172.17.0.3%3A12800%2Flogin%3C%2FA%3E%20%7C%20jq%20-r%20'.access_token'%20%3CBR%20%2F%3E%20%3CACCESS%20token%3D%22%22%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20curl%20-s%20--header%20%22Content-Type%3A%20application%2Fjson%22%20--header%20%22Authorization%3A%20Bearer%20%3CACCESS%20token%3D%22%22%3E%22%20--request%20POST%20--data%20'%7B%22hp%22%3A120%2C%22wt%22%3A2.8%7D'%20%3CA%20href%3D%22http%3A%2F%2F172.17.0.3%3A12800%2Fapi%2FManualTransmissionService%2F1.0.0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F172.17.0.3%3A12800%2Fapi%2FManualTransmissionService%2F1.0.0%3C%2FA%3E%20%3CBR%20%2F%3E%20%7B%22success%22%3Atrue%2C%22errorMessage%22%3A%22%22%2C%22outputParameters%22%3A%7B%22answer%22%3A0.64181252840938208%7D%2C%22outputFiles%22%3A%7B%7D%2C%22consoleOutput%22%3A%22%22%2C%22changedFiles%22%3A%5B%5D%7D%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20curl%20-s%20--header%20%22Authorization%3A%20Bearer%20%3CACCESS%20token%3D%22%22%3E%22%20--request%20GET%20%3CA%20href%3D%22http%3A%2F%2F172.17.0.3%3A12800%2Fapi%2FManualTransmissionService%2F1.0.0%2Fswagger.json%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F172.17.0.3%3A12800%2Fapi%2FManualTransmissionService%2F1.0.0%2Fswagger.json%3C%2FA%3E%20-o%20swagger.json%20%3CBR%20%2F%3E%20The%20swagger.json%20file%20can%20then%20be%20used%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmachine-learning-server%2Foperationalize%2Fhow-to-build-api-clients-from-swagger-for-app-integration%23option-2-build-using-an-online-swagger-editor%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20build%20a%20client%20library%20in%20any%20language%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId-1608359868%22%20id%3D%22toc-hId-1632366584%22%3E%3CSTRONG%3E%20Run%20Python%20Web%20Service%20%3A%20%3C%2FSTRONG%3E%3C%2FH3%3E%3CBR%20%2F%3E%20Here%20is%20an%20example%20to%20build%20an%20image%20with%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FMicrosoft%2FML-Server-Python-Samples%2Fblob%2Fmaster%2Foperationalize%2FQuickstart_Publish_Python_Web_Service.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Manual%20Transmission%20Python%20Web%20Service%20%3C%2FA%3E%20pre-configured%20inside%20the%20image.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Build%20image%20%22pymanualtransmission%22%20using%20the%20above%20dockerfile%20%3A%20%3CBR%20%2F%3E%20docker%20build%20-f%20py-manualtransmission-dockerfile%20-t%20pymanualtransmission%20.%20%3CBR%20%2F%3E%20Check%20if%20image%20%22pymanualtransmission%22%20is%20built%20successfully%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20images%20%3CBR%20%2F%3E%20Start%20container%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20run%20--name%20pymanualtransmission-container%20-dit%20pymanualtransmission%20%3CBR%20%2F%3E%20Check%20the%20status%20of%20container%20using%20%3A%20%3CBR%20%2F%3E%20docker%20logs%20pymanualtransmission-container%20%3CBR%20%2F%3E%20Once%20you%20have%20confirmed%20that%20the%20diagnostic%20tests%20have%20passed%20successfully%20and%20web%20service%20has%20been%20published%2C%20you%20can%20start%20consuming%20the%20web%20service.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Obtain%20the%20IP%20address%20of%20the%20container%20using%20the%20following%20command%20%3A%20%3CBR%20%2F%3E%20docker%20inspect%20-f%20'%7B%7Brange%20.NetworkSettings.Networks%7D%7D%7B%7B.IPAddress%7D%7D%7B%7Bend%7D%7D'%20pymanualtransmission-container%20%3CBR%20%2F%3E%20'172.17.0.3'%20%3CBR%20%2F%3E%20you%20can%20obtain%20the%20swagger.json%20of%20ManualTranmission%20Python%20Web%20Service%20using%20curl%20commands%20%3A%20%3CBR%20%2F%3E%20apt-get%20-y%20install%20jq%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20curl%20-s%20--header%20%22Content-Type%3A%20application%2Fjson%22%20--request%20POST%20--data%20'%7B%22username%22%3A%22admin%22%2C%22password%22%3A%22Microsoft%402018%22%7D'%20%3CA%20href%3D%22http%3A%2F%2F172.17.0.3%3A12800%2Flogin%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F172.17.0.3%3A12800%2Flogin%3C%2FA%3E%20%7C%20jq%20-r%20'.access_token'%20%3CBR%20%2F%3E%20%3CACCESS%20token%3D%22%22%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20curl%20-s%20--header%20%22Content-Type%3A%20application%2Fjson%22%20--header%20%22Authorization%3A%20Bearer%20%3CACCESS%20token%3D%22%22%3E%22%20--request%20POST%20--data%20'%7B%22hp%22%3A120%2C%22wt%22%3A2.8%7D'%20%3CA%20href%3D%22http%3A%2F%2F172.17.0.3%3A12800%2Fapi%2FManualTransmissionService%2F1.0.0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F172.17.0.3%3A12800%2Fapi%2FManualTransmissionService%2F1.0.0%3C%2FA%3E%20%3CBR%20%2F%3E%20%7B%22success%22%3Atrue%2C%22errorMessage%22%3A%22%22%2C%22outputParameters%22%3A%7B%22answer%22%3A0.64181252840938208%7D%2C%22outputFiles%22%3A%7B%7D%2C%22consoleOutput%22%3A%22%22%2C%22changedFiles%22%3A%5B%5D%7D%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20curl%20-s%20--header%20%22Authorization%3A%20Bearer%20%3CACCESS%20token%3D%22%22%3E%22%20--request%20GET%20%3CA%20href%3D%22http%3A%2F%2F172.17.0.3%3A12800%2Fapi%2FManualTransmissionService%2F1.0.0%2Fswagger.json%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2F172.17.0.3%3A12800%2Fapi%2FManualTransmissionService%2F1.0.0%2Fswagger.json%3C%2FA%3E%20-o%20swagger.json%20%3CBR%20%2F%3E%20The%20swagger.json%20file%20can%20then%20be%20used%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmachine-learning-server%2Foperationalize%2Fhow-to-build-api-clients-from-swagger-for-app-integration%23option-2-build-using-an-online-swagger-editor%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20build%20a%20client%20library%20in%20any%20language%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3ENOTE%20%3C%2FSTRONG%3E%20%3A%20You%20can%20also%20modify%20webnode%20appsettings.json%20using%20Dockerfile%20magic%20and%20enable%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmachine-learning-server%2Foperationalize%2Fconfigure-authentication%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20LDAP%2FAAD%20Authentication%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId--943797093%22%20id%3D%22toc-hId--919790377%22%3E%3CSTRONG%3E%20Run%20on%20Kubernetes%20%3A%20%3C%2FSTRONG%3E%3C%2FH3%3E%3CBR%20%2F%3E%20The%20developed%20local%20docker%20images%20can%20be%20pushed%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcontainer-registry%2Fcontainer-registry-get-started-docker-cli%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Azure%20Container%20Registry%20%3C%2FA%3E%20(ACR).%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Faks%2Ftutorial-kubernetes-deploy-cluster%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3ECreate%20Azure%20Kubernetes%20Service%20(AKS)%20%3C%2FA%3E%20cluster%20using%20images%20in%20ACR%20which%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Faks%2Ftutorial-kubernetes-scale%23autoscale-pods%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20can%20be%20scaled%20up%20and%20down%20automatically%20using%20Autoscale%20pods.%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20In%20order%20to%20run%209.3%20linux%20onebox%20image%20in%20a%20Kubernetes%20Cluster%2C%20we%20will%20have%20to%20initialize%20JWTSigningCertificate%20with%20a%20certificate%20value%20and%20add%20%22kubepods%22%20group%20to%20webnode%2Fcomputenode%20autoStartScripts.%20These%20extra%20steps%20can%20be%20added%20to%20the%20dockerfile%20as%20follows%20%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId-799013242%22%20id%3D%22toc-hId-823019958%22%3EREFERENCES%20%3A%3C%2FH3%3E%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fjohnpaulada%2Fmicrosoftmlserver-docker%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fjohnpaulada%2Fmicrosoftmlserver-docker%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Frcarmo%2Fdocker-ml-server%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fgithub.com%2Frcarmo%2Fdocker-ml-server%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fsuccess.docker.com%2Farticle%2Fuse-a-script-to-initialize-stateful-container-data%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fsuccess.docker.com%2Farticle%2Fuse-a-script-to-initialize-stateful-container-data%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fdocs.docker.com%2Fv17.09%2Fengine%2Fuserguide%2Feng-image%2Fdockerfile_best-practices%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fdocs.docker.com%2Fv17.09%2Fengine%2Fuserguide%2Feng-image%2Fdockerfile_best-practices%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22http%3A%2F%2Fwww.tothenew.com%2Fblog%2Fdockerizing-nginx-and-ssh-using-supervisord%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20http%3A%2F%2Fwww.tothenew.com%2Fblog%2Fdockerizing-nginx-and-ssh-using-supervisord%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fmicrosoft.github.io%2Fdeployr-api-docs%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fmicrosoft.github.io%2Fdeployr-api-docs%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fstandard%2Fmicroservices-architecture%2Fcontainer-docker-introduction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fstandard%2Fmicroservices-architecture%2Fcontainer-docker-introduction%3C%2FA%3E%3C%2FACCESS%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-385970%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Jul%2026%2C%202018%20Containerization%20is%20an%20approach%20to%20software%20development%20in%20which%20an%20application%20or%20service%2C%20its%20dependencies%2C%20and%20its%20configuration%20(abstracted%20as%20deployment%20manifest%20files)%20are%20packaged%20together%20as%20a%20container%20image.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-385970%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESQLServerMachineLearning%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-401041%22%20slang%3D%22en-US%22%3ERe%3A%20Dockerizing%20R%20and%20Python%20Web%20Services%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-401041%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgist.github.com%2Framnov%2Fa927a97438819df547a7bbd13b404386%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgist.github.com%2Framnov%2Fa927a97438819df547a7bbd13b404386%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgist.github.com%2Framnov%2Fde62737a1146e50ad0125f018eafae6a%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgist.github.com%2Framnov%2Fde62737a1146e50ad0125f018eafae6a%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgist.github.com%2Framnov%2F0532070291d2a7af1934898b0e85d32b%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgist.github.com%2Framnov%2F0532070291d2a7af1934898b0e85d32b%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-393719%22%20slang%3D%22en-US%22%3ERe%3A%20Dockerizing%20R%20and%20Python%20Web%20Services%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-393719%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20it%20only%20me%2C%20or%20the%20article%20is%20missing%20referenced%20Dockerfiles%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhere%20can%20I%20find%20content%20of%20the%20following%20files%3A%3C%2FP%3E%3CP%3E*%26nbsp%3B%3CSPAN%3Emlserver-dockerfile%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E*%26nbsp%3B%3CSPAN%3Emlserver-onebox-dockerfile%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E*%26nbsp%3B%3CSPAN%3Er-manualtransmission-dockerfile%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3C%2FACCESS%3E%3C%2FACCESS%3E%3C%2FACCESS%3E%3C%2FACCESS%3E%3C%2FACCESS%3E%3C%2FLINGO-BODY%3E
Microsoft
First published on MSDN on Jul 26, 2018
Containerization is an approach to software development in which an application or service, its dependencies, and its configuration (abstracted as deployment manifest files) are packaged together as a container image. The containerized application can be tested as a unit and deployed as a container image instance to the host operating system (OS). Docker is an open-source project for automating the deployment of applications as portable, self-sufficient containers that can run on the cloud or on-premises. More information here.

Microsoft Machine Learning Server is your flexible enterprise platform for analyzing data at scale, building intelligent apps, and discovering valuable insights across your business with full support for Python and R. Operationalization refers to the process of deploying R and Python models and code to Machine Learning Server in the form of web services and the subsequent consumption of these services within client applications to affect business results.

In this article, We will look into how to build a docker image containing Machine Learning Server 9.3 using Dockerfiles and how-to-perform the following operations using the docker image :

  1. Run R Shell

  2. Run Python Shell

  3. Run Jupyter Notebook

  4. Run Onebox Configuration

  5. Run R Web Service

  6. Run Python Web Service



Prerequisites :
Any Linux VM with docker community edition installed. For this article, I have spinned a Ubuntu 16.04 VM and installed docker CE.
Step 0 :
First let us create an image called "mlserver" with Machine Learning Server 9.3 installed using the following Dockerfile :



Use docker build command to build image "mlserver" using the above dockerfile :
docker build -f mlserver-dockerfile -t mlserver .
Check if image "mlserver" is built successfully using the following command :
docker images

Run R Shell


docker run -it mlserver R

Run Python Shell :


docker run -it mlserver mlserver-python

Run Jupyter Notebook :


docker run -p 8888:8888 -it mlserver /opt/microsoft/mlserver/9.3.0/runtime/python/bin/jupyter notebook --no-browser --port=8888 --ip=0.0.0.0 --allow-root
Running the above command gives a link that you can open in your browser to use Jupyter Notebooks.

Run One-box Configuration :


You can configure Microsoft Learning Server after installation to act as a deployment server and to host analytic web services for operationalization .



Build image "mlserver-onebox" using the above dockerfile :
docker build -f mlserver-onebox-dockerfile -t mlserver-onebox .
Check if image "mlserver-onebox" is built successfully using the following command :
docker images
Start a onebox container using the following command :
docker run --name mlserver-onebox-container -dit mlserver-onebox
Check the status of container using :
docker logs mlserver-onebox-container
Once you have confirmed that the diagnostic tests have passed successfully from the above command, you can start using it as one-box. (docker logs output should contain the following string : "All Diagnostic Tests have passed.")

Obtain the IP address of the container using the following command :
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mlserver-onebox-container
'172.17.0.3'
and use it like a one-box :
az login --mls --mls-endpoint "http://172.17.0.3:12800" --username "admin" --password "Microsoft@2018"
az ml admin diagnostic run

Run R Web Service :


We can also develop an image with a webservice pre-configured so that it is ready for consumption as soon as we spin a container. Here is an example to build an image with Manual Transmission R Web Service pre-configured inside the image.



Build image "rmanualtransmission" using the above dockerfile :
docker build -f r-manualtransmission-dockerfile -t rmanualtransmission .
Check if image "rmanualtransmission" is built successfully using the following command :
docker images
Start container using the following command :
docker run --name rmanualtransmission-container -dit rmanualtransmission
Check the status of container using :
docker logs rmanualtransmission-container
Once you have confirmed that the diagnostic tests have passed successfully and web service has been published, you can start consuming the web service.

Obtain the IP address of the container using the following command :
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' rmanualtransmission-container
'172.17.0.3'
you can consume (or) obtain the swagger.json of ManualTranmission R Web Service using curl commands :
apt-get -y install jq

curl -s --header "Content-Type: application/json" --request POST --data '{"username":"admin","password":"Microsoft@2018"}' http://172.17.0.3:12800/login | jq -r '.access_token'
<access token>

curl -s --header "Content-Type: application/json" --header "Authorization: Bearer <access token>" --request POST --data '{"hp":120,"wt":2.8}' http://172.17.0.3:12800/api/ManualTransmissionService/1.0.0
{"success":true,"errorMessage":"","outputParameters":{"answer":0.64181252840938208},"outputFiles":{},"consoleOutput":"","changedFiles":[]}

curl -s --header "Authorization: Bearer <access token>" --request GET http://172.17.0.3:12800/api/ManualTransmissionService/1.0.0/swagger.json -o swagger.json
The swagger.json file can then be used to build a client library in any language .

Run Python Web Service :


Here is an example to build an image with Manual Transmission Python Web Service pre-configured inside the image.



Build image "pymanualtransmission" using the above dockerfile :
docker build -f py-manualtransmission-dockerfile -t pymanualtransmission .
Check if image "pymanualtransmission" is built successfully using the following command :
docker images
Start container using the following command :
docker run --name pymanualtransmission-container -dit pymanualtransmission
Check the status of container using :
docker logs pymanualtransmission-container
Once you have confirmed that the diagnostic tests have passed successfully and web service has been published, you can start consuming the web service.

Obtain the IP address of the container using the following command :
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pymanualtransmission-container
'172.17.0.3'
you can obtain the swagger.json of ManualTranmission Python Web Service using curl commands :
apt-get -y install jq

curl -s --header "Content-Type: application/json" --request POST --data '{"username":"admin","password":"Microsoft@2018"}' http://172.17.0.3:12800/login | jq -r '.access_token'
<access token>

curl -s --header "Content-Type: application/json" --header "Authorization: Bearer <access token>" --request POST --data '{"hp":120,"wt":2.8}' http://172.17.0.3:12800/api/ManualTransmissionService/1.0.0
{"success":true,"errorMessage":"","outputParameters":{"answer":0.64181252840938208},"outputFiles":{},"consoleOutput":"","changedFiles":[]}

curl -s --header "Authorization: Bearer <access token>" --request GET http://172.17.0.3:12800/api/ManualTransmissionService/1.0.0/swagger.json -o swagger.json
The swagger.json file can then be used to build a client library in any language .

NOTE : You can also modify webnode appsettings.json using Dockerfile magic and enable LDAP/AAD Authentication .

Run on Kubernetes :


The developed local docker images can be pushed to Azure Container Registry (ACR).

Create Azure Kubernetes Service (AKS) cluster using images in ACR which can be scaled up and down automatically using Autoscale pods.

In order to run 9.3 linux onebox image in a Kubernetes Cluster, we will have to initialize JWTSigningCertificate with a certificate value and add "kubepods" group to webnode/computenode autoStartScripts. These extra steps can be added to the dockerfile as follows :


REFERENCES :


https://github.com/johnpaulada/microsoftmlserver-docker

https://github.com/rcarmo/docker-ml-server

https://success.docker.com/article/use-a-script-to-initialize-stateful-container-data

https://docs.docker.com/v17.09/engine/userguide/eng-image/dockerfile_best-practices

http://www.tothenew.com/blog/dockerizing-nginx-and-ssh-using-supervisord

https://microsoft.github.io/deployr-api-docs

https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/container-docker-int...
2 Comments
Regular Visitor

Is it only me, or the article is missing referenced Dockerfiles?

 

Where can I find content of the following files:

mlserver-dockerfile,

mlserver-onebox-dockerfile,

r-manualtransmission-dockerfile?