MacOS Docker

MacOS上运行Docker容器流程:

  1. 创建Dockerfile
  FROM arm64v8/ubuntu:22.04 AS builder

  RUN sed -i 's|ports.ubuntu.com|mirrors.tuna.tsinghua.edu.cn/ubuntu-ports|g' /etc/apt/sources.list && \
      apt-get update && \
      apt-get install -y build-essential

  FROM arm64v8/ubuntu:22.04

  COPY --from=builder /etc/apt/sources.list /etc/apt/

  RUN apt-get update && \
      apt-get install -y python3 && \
      apt-get install -y gcc make flex bison libssl-dev bc vim qemu-system-aarch64 && \
      rm -rf /var/lib/apt/lists/*
  WORKDIR /root
  CMD tail -f /dev/null          
  1. docker build生成image,可选镜像CPU架构
    docker build --platform linux/arm64 --network=host -t arm64-ubuntu .
  2. docker run运行实例并启动交互bash
    docker run -it arm64-ubuntu bash

docker cheetsheet
dockerHUB国内镜像
docker Desktop配置镜像源
docker arm配置apt源

posted @ 2025-04-06 10:04  3yearleft  阅读(34)  评论(0)    收藏  举报