docker 软件dmg下载:https://download.docker.com/mac/stable/Docker.dmg
安装完成后就可以用了。
配置国内镜像偏好设置里registry-mirrors中添加
https://docker.mirrors.ustc.edu.cn https://hub-mirror.c.163.com
docker images :查看镜像,还没有。
docker search python :搜索python相关的docker镜像。
docker pull centos/python-27-centos7: 下载镜像
创建目录,进入目录
cd ~/python
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos/python-27-centos7 latest f5b35a5f05a7 2 weeks ago 644MB
dockerfile 文件: https://hub.docker.com/_/python/
创建容器
docker build --force-rm -t cli-python:0.1 .
查看:
docker images REPOSITORY TAG IMAGE ID CREATED SIZE8d047b05f0bb 2 minutes ago 61.7MB centos/python-27-centos7 latest f5b35a5f05a7 2 weeks ago 644MB debian stretch-slim 4b4471f624dc 4 weeks ago 55.3MB $docker run -itd --name cli-python debian:stretch-slim bash 8e76447042ab15899fefa8bc4ed4d8c484f1e1f9870c1be0cbf1cb2570705e5a
docker ps查看
docker exec -it 8e76447042ab bash
进入容器,执行命令
apt-get update apt-get install python
查看全部容器:
docker ps -a
删除多余容器:
docker rm -f containerid
查看镜像:
docker images
删除多余镜像:
docker rmi -f imageid
查看docker信息:
docker info
使用当前目录的 Dockerfile 创建镜像,标签为 runoob/ubuntu:v1。
docker build -t runoob/ubuntu:v1 .
使用URL github.com/creack/docker-firefox 的 Dockerfile 创建镜像。
docker build github.com/creack/docker-firefox
也可以通过 -f Dockerfile 文件的位置:
$ docker build -f /path/to/a/Dockerfile .
在 Docker 守护进程执行 Dockerfile 中的指令前,首先会对 Dockerfile 进行语法检查,有语法错误时会返回:
$ docker build -t test/myapp .
Sending build context to Docker daemon 2.048 kB
Error response from daemon: Unknown instruction: RUNCMD
后续操作
# 应用安装 apt-get update apt-get install vim apt-get install python apt-cache search pip apt-get install python-pip pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt # 提交镜像 docker commit CONTAINER_ID IMAGE_ID docker commit 8e76447042ab 4b4471f624dc