下载 Docker
Docker 镜像
- Docker 镜像是项目的模板(蓝图)
- 图像无法更新,它是只读的
- 它有源代码、库、外部依赖项、工具等
Docker容器
- 容器是镜像的运行实例
- 它在计算机上独立运行,因此我们可以称之为,它是一个独立的进程
Docker 基础镜像或父镜像
- 示例Python编程镜像,我们可以从Docker hub官方网站下载
我们如何创建 Docker 镜像
- 要创建 Docker 映像,我们将详细信息写入包含构建映像的说明的 Dockerfile 中。当我们构建这个 Dockerfile 时,会生成一个镜像,然后我们可以将其作为容器运行。
现在让我们继续设置并运行
下载docker桌面后
在 docker hub 中搜索 Python 基础镜像,使用终端或 Docker 桌面拉取它
-
使用终端或 Docker 桌面运行
docker run -it --name rajnish_python python /bin/bash
现在转到 docker 桌面上的 Container,看看它是否正在运行。
- 打开Container并通过检查python版本来进一步探索它
让我们创建一个基本的 Python Flask Web 应用程序并通过 docker 运行它
- 您可以创建一个新的网络应用程序,或者只是克隆我的存储库生产力
git 克隆 https://github.com/rajnishspandey/productivity.git
这里我创建了一个项目,它在我的本地,我想在 github 上创建一个新的存储库并从我的终端推送它
git 初始化
如果你想删除初始化的 git,你可以运行下面的命令并再次执行 git init 来添加。
rm -rf git
git add .
git commit -m '初始提交'
- 我在 github 上创建了一个名为 Productivity 的存储库,并将其与我的本地/远程 git 链接
git 远程 set-url 来源 https://github.com/rajnishspandey/productivity.git
git push -u origin master
- 现在让我们构建应用程序并将应用程序的所有文件复制到容器中 > docker build -t 生产力应用程序。
检查 docker 中有多少镜像的命令
在终端中运行 docker 镜像
我们现在可以看到新的镜像已经在docker中创建了
现在我们必须通过容器来运行它
- 点击端口 5500:5000
它会将您重定向到浏览器,您应该会看到应用程序正在运行
来自官方网站的 Docker 命令列表
一些有用的 docker 命令
- docker images 检查所有镜像
-
docker build -t
-app 。从您的应用程序构建图像 -
docker image rm
; - 删除未使用的图像 -
docker run -it --name
; /bin/bash 创建一个新容器并从基本映像运行它。 (上面我们有 python 作为基础镜像) -
docker image rm
; -f 强制删除正在使用的镜像 - docker ps -a 查看所有正在运行的容器
- docker 容器 rm ;删除未运行的容器
- docker 容器 rm ; -f 强制删除正在运行的容器
- docker system prune -a 删除所有容器、镜像和缓存。
- docker compose up 运行 docker compose 文件并创建镜像
以上是从设置到部署:在 Mac 上的 Docker 中运行 Flask 应用程序的详细内容。更多信息请关注PHP中文网其他相关文章!

ForhandlinglargedatasetsinPython,useNumPyarraysforbetterperformance.1)NumPyarraysarememory-efficientandfasterfornumericaloperations.2)Avoidunnecessarytypeconversions.3)Leveragevectorizationforreducedtimecomplexity.4)Managememoryusagewithefficientdata

Inpython,ListSusedynamicMemoryAllocationWithOver-Asalose,而alenumpyArraySallaySallocateFixedMemory.1)listssallocatemoremoremoremorythanneededinentientary上,respizeTized.2)numpyarsallaysallaysallocateAllocateAllocateAlcocateExactMemoryForements,OfferingPrediCtableSageButlessemageButlesseflextlessibility。

Inpython,YouCansspecthedatatAtatatPeyFelemereModeRernSpant.1)Usenpynernrump.1)Usenpynyp.dloatp.dloatp.ploatm64,formor professisconsiscontrolatatypes。

NumPyisessentialfornumericalcomputinginPythonduetoitsspeed,memoryefficiency,andcomprehensivemathematicalfunctions.1)It'sfastbecauseitperformsoperationsinC.2)NumPyarraysaremorememory-efficientthanPythonlists.3)Itoffersawiderangeofmathematicaloperation

Contiguousmemoryallocationiscrucialforarraysbecauseitallowsforefficientandfastelementaccess.1)Itenablesconstanttimeaccess,O(1),duetodirectaddresscalculation.2)Itimprovescacheefficiencybyallowingmultipleelementfetchespercacheline.3)Itsimplifiesmemorym

SlicingaPythonlistisdoneusingthesyntaxlist[start:stop:step].Here'showitworks:1)Startistheindexofthefirstelementtoinclude.2)Stopistheindexofthefirstelementtoexclude.3)Stepistheincrementbetweenelements.It'susefulforextractingportionsoflistsandcanuseneg

numpyallowsforvariousoperationsonArrays:1)basicarithmeticlikeaddition,减法,乘法和division; 2)evationAperationssuchasmatrixmultiplication; 3)element-wiseOperations wiseOperationswithOutexpliitloops; 4)

Arresinpython,尤其是Throughnumpyandpandas,weessentialFordataAnalysis,offeringSpeedAndeffied.1)NumpyArseNable efflaysenable efficefliceHandlingAtaSetSetSetSetSetSetSetSetSetSetSetsetSetSetSetSetsopplexoperationslikemovingaverages.2)


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3 Linux新版
SublimeText3 Linux最新版

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),