比如给到一个Dockerfile
第一步编译镜像
bash
cd /path/to/Dockerfile
docker build -t <DOCKER_IMAGE_NAME> .
build 命令编译镜像
-t 镜像名字
. 指dockerfile 所在目录
如果遇到报错
bash
[+] Building 0.3s (3/3) FINISHED docker:default
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.15kB 0.0s
=> ERROR [internal] load metadata for docker.io/library/ubuntu:20.04
可能是因为墙的问题,需要修改aliyun mirror 地址
参考https://blog.csdn.net/yishengzhiai005/article/details/142717481
https://github.com/tech-shrimp/docker_installer
bash
sudo vi /etc/docker/daemon.json
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://docker.1panel.live",
"https://hub.rat.dev"
]
}