docker image
查看docker image command
docker pull nginx
镜像的拉取 默认最新
docker pull nginx:1.20.0
指定版本拉取
docker pull quay.io/bitnami/nginx
从Quay上拉取镜像
docker image ls
镜像的查看
docker image rm 0922eabe1625
镜像的删除(如果镜像有container 需要先删除cintainer再删除否则不成功 停止也不行)
导出:docker image save nginx:latest -o nginx.image
导入:docker image load -i ./nginx.image
执行python等同于下面的dockerfile
print("hello docker")
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3.9 python3-pip python3.9-dev
$ python3 hello.py
hello docker
DockerFile
FROM ubuntu:20.04
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3.9 python3-pip python3.9-dev
ADD hello.py /
CMD ["python3", "/hello.py"]
构建:docker image build -t [名字]:[版本] [dockerfile位置]
根据已存在的image创建一个新image:docker image tag [旧名字] [新名字]
分享(push到dockerhub)
docker container run -d -p 8080:80 nginx
docker exec -it 7c /bin/bash
echo "Hello Docker
" > index.html
docker container stop 7c
docker container commit 7c1 samsun1997