docker for linux(5)

  1. docker 创建镜像

              创建镜像两种方式:
                        更新镜像: docker commit
                        构建镜像: docker build
  2. 更新镜像: 先更进基础镜像,创建一个容器,然后对容器进行修改,最后commit命令提交
    • 创建容器:$ sudo docker run --name mytomcat -p 8080:8080 -d tomcat:latest
    • 进入容器:$ sudo docker exec -it 1c644e0a20b8 /bin/bash
    • 修改容器启动页面:mv index.jsp index.jsp_bak \ echo welcome to tomcat > index.html
  3. 提交自定义镜像:docker commit -m="" -a="" 容器ID或名称 镜像名:tag

    • $ sudo docker commit -m="修改默认首页" -a="xianwei" 1c644e0a20b8 home/python:v1
  4. 运行自定义镜像
    • $ sudo docker run --name tomcat_v1 -p 8090:8080 -d home/python:v1

猜你喜欢

转载自blog.51cto.com/11726705/2334224