docker提交镜像到阿里ack整体流程

本文档详细记录了使用Docker构建镜像,并将其推送到阿里云ACK(Alibaba Cloud Container Service for Kubernetes)的过程。首先,通过`docker login`登录阿里云Docker仓库,然后创建Dockerfile,将math.py和run.sh文件添加到镜像中,最后运行`docker build`构建镜像。镜像构建成功后,使用`docker push`将其推送到阿里云仓库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本笔记为阿里云天池龙珠计划Docker训练营的学习内容,链接为:https://tianchi.aliyun.com/specials/activity/promotion/aicampdocker;

➜  testv0928 mkdir docker_test01
➜  testv0928 cd docker_test01 

使用ack账号登陆docker
➜  docker_test01 docker login --username=**** registry.cn-hangzhou.aliyuncs.com
  Password: 
  Login Succeeded
  Logging in with your password grants your terminal complete access to your account. 
  For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/
➜  docker_test01 vim math.py
➜  docker_test01 vim run.sh
➜  docker_test01 cat math.py
  import torch
  device = torch.device("cuda")
  a = torch.randn(3, 3)
  b = torch.randn(3, 3)
  a = a.to(device)
  b = b.to(device)
  c = torch.matmul(a,b)
  print(c)
➜  docker_test01 cat run.sh
  #bin/bash
  #打印GPU信息
  nvidia-smi
  #执行math.py
  python3 math.py
➜  docker_test01 vim Dockerfile
➜  docker_test01 cat Dockerfile 
  # Base Images
  ## 从天池基础镜像构建(from的base img 根据自己的需要更换,建议使用天池open list镜像链接:https://tianchi.aliyun.com/forum/postDetail?postId=67720)
  FROM registry.cn-shanghai.aliyuncs.com/tcc-public/pytorch:1.4-cuda10.1-py3
  
  ##安装依赖包,pip包请在requirements.txt添加
  #RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
  
  ## 把当前文件夹里的文件构建到镜像的//workspace目录下,并设置为默认工作目录
  ADD math.py /workspace
  ADD run.sh /workspace
  WORKDIR /workspace
  
  ## 镜像启动后统一执行 sh run.sh
  CMD ["sh", "run.sh"]
➜  docker_test01 docker build -t registry.cn-hangzhou.aliyuncs.com/ly_22_test/docker_test01:01
  "docker build" requires exactly 1 argument.
  See 'docker build --help'.
  
  Usage:  docker build [OPTIONS] PATH | URL | -
  
  Build an image from a Dockerfile
➜  docker_test01 ls                                                                           
    Dockerfile math.py    run.sh
➜  docker_test01 ll
  total 24
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卑微-程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值