带有不同拱门的Docker图像很好,为什么?
我试图弄清楚为什么我使用英特尔MacBook构建的Docker映像在我的M1 MacBook上作品(它确实吐出了有关平台的警告,但仍在运行)。
在我的Intel机器上,我创建了一个简单的Python脚本Dockerfile,并构建并推动了图像。
# hello_world.py
def hello_world():
print("hello world")
if __name__ == "__main__":
hello_world()
对于Dockerfile ...
FROM python:3.9-buster
WORKDIR /src
COPY ./hello_world.py /src/hello_world.py
CMD ["python3", "hello_world.py"]
对于构建和推动
$ docker build -t jduran9987/hello_world:single-arch .
$ docker push jduran9987/hello_world:single-arch
DockerHub,支持的OS/Arch说Linux/AMD64
,如预期。
但是,我能够在我的M1机器上成功运行Hello_world.py
脚本,尽管我确实收到了有关不同平台的警告。
我感到困惑,因为我不希望能够在M1上运行图像(linux/arm64
拱门)。有人可以给我一些见解吗?
- 仅供参考,我知道如何构建多个架构图像,只是为何使用一个拱门在另一个拱门上构建的图像感到困惑。
I am trying to figure out why a Docker image that I built using my Intel Macbook works on my M1 Macbook (It does spit out a warning about the platform but still runs).
On my Intel machine, I created a simple Python script, Dockerfile, and build and pushed the image.
# hello_world.py
def hello_world():
print("hello world")
if __name__ == "__main__":
hello_world()
For the Dockerfile...
FROM python:3.9-buster
WORKDIR /src
COPY ./hello_world.py /src/hello_world.py
CMD ["python3", "hello_world.py"]
For the build and push
$ docker build -t jduran9987/hello_world:single-arch .
$ docker push jduran9987/hello_world:single-arch
On DockerHub, the supported OS/ARCH says linux/amd64
as expected.
However, I am able to successfully run the hello_world.py
script on my M1 machine, though I do receive a warning about the different platforms.
I am confused because I was not expecting to be able to run the image on my M1 (linux/arm64
arch). Can someone give me some insight into this?
- FYI, I know how to build multi-arch images, just confused as to why an image that was built using one arch works on another.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论