1.1 将应用作者的源码拷贝到本地
git clone [url]
举个例子:
git clone https://github.com/zmister2016/MrDoc
但是一般从GitHub上拉代码仓库不稳定,会提示失败,需要设置代理
解决方案:
git clone https://ghproxy.com/https://github.com/stilleshan/ServerStatus
1.2 使用源码中的 dockerfile 创建应用镜像
- 进入到 dockerfile 所在目录
- 参考https://www.runoob.com/docker/docker-build-command.html
【推荐】使用当前目录的 Dockerfile 创建镜像,标签为 runoob/ubuntu:v1。
一般镜像名称和版本号都为小写字母
docker build -t runoob/ubuntu:v1 .
通过 -f Dockerfile 文件的位置:
$ docker build -f /path/to/a/Dockerfile .
使用URLgithub.com/creack/docker-firefox的 Dockerfile 创建镜像(
因为上下文的原因,不推荐使用URL创建)
docker build github.com/creack/docker-firefox
在 Docker 守护进程执行 Dockerfile 中的指令前,首先会对 Dockerfile 进行语法检查,有语法错误时会返回:
$ docker build -t test/myapp .
Sending build context to Docker daemon 2.048 kB
Error response from daemon: Unknown instruction: RUNCMD
构建成功之后,使用 docker images 查看镜像信息
1.3 改造作者的 docker-compose.yml 文件
修改里面的镜像名称、路径、端口号、管理员用户密码等信息,保存
1.4 执行 docker-compose up -d ,配置服务、启动服务
要在 docker-compose.yml 路径下执行
如果你想在后台执行该服务可以加上-d参数:
1.5 查看该容器是否运行中
docker-compose ps
1.6 如果想要停止容器
docker stop [OPTIONS] CONTAINER [CONTAINER...]
1.7 如果要删除一个容器
docker rm [OPTIONS] CONTAINER [CONTAINER...]