- Dockerfile是用于构建docker镜像的文件
- Dockerfile里包含了构建镜像所需的“指令”
- Dockerfile有其特定的语法规则
举例:执行一个Python程序
编写Python程序
编写Dockerfileprint("hello docker")
创建镜像FROM ubuntu:21.04RUN apt-get update && \DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3.9 python3-pip python3.9-devADD hello.py /CMD ["python3", "/hello.py"]
提交docker image build -t hello .
docker container commit id dockerid/imagename镜像的导入导出
save
docker save -o nginx.tar nginx:latest
load
docker load -i nginx.tar
export
其中-o表示输出到文件,nginx-test.tar为目标文件,nginx-test是源容器名(name)docker export -o nginx-test.tar nginx-test
import
示例docker import nginx-test.tar nginx:imp或cat nginx-test.tar | docker import - nginx:imp
