zoukankan      html  css  js  c++  java
  • docker常用命令

    --Dockerfile 内容
    # 基于哪个镜像
     1 FROM java:8 

    # 将本地文件夹挂载到当前容器
     1 VOLUME /tmp 

    # 复制文件到容器

    1 ADD liuxiaofeng-module-system-2.2.0.jar(文件名) liuxiaofeng-module-system.jar(重命名)
    2 RUN bash -c 'touch /liuxiaofeng-module-system.jar'
    View Code

    # 声明需要暴露的端口

    1 EXPOSE 8687
    View Code

    # 配置容器启动后执行的命令

    1 ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/liuxiaofeng-module-system.jar"]
    View Code

    --构建和运行容器
    1、下载java8镜像 注:最开始的时候才需要

    1 docker run java /bin/echo 'hello world'
    View Code

    2、构建镜像(在Dockerfile路径下)

    1 docker build -t liuxiaofeng-module-system(镜像名称) .(本地路径)
    View Code

    3、运行docker镜像

    1 docker run --name liuxiaofeng-module-system(命名) -d -p 8687:8687(指定端口) liuxiaofeng-module-system(指定镜像)
    View Code

    --删除容器和镜像
    1、列出所有容器

    1 docker container ls -a
    View Code

    2、删除容器

    1 docker rm 容器id 注:若提示在运行状态,则 docker kill 容器id
    View Code

    3、列出所有镜像

    1 docker images
    View Code

    4、删除镜像

    1 docker rmi 镜像id
    View Code

    --启动已存在容器

    1 docker start 容器id
    View Code
  • 相关阅读:
    Win下循环进入目录启动执行某任务
    Mysql数据库搭建-Windows
    Linux的服务器初始优化脚本。
    Linux下Find命令的使用
    一些判断Linux是否被黑的经验
    搭建docker私有仓库
    进程退出:SIGINT、SIGTERM和SIGKILL区别
    dockerfile使用
    k8s-ingress安装
    k8s-service
  • 原文地址:https://www.cnblogs.com/yenengfeng/p/14623620.html
Copyright © 2011-2022 走看看