📗
Notes
  • Introduction
  • Files
  • Android
    • Http
      • Http基础
      • Okhttp理解
    • Jetpack
      • Notes
  • Java ways
    • 101
      • Basis
        • Index
        • Front
          • Angular
            • Angular start 01
            • Angular start 02
          • Typescript
            • Index
            • Ts 01
        • Java
          • Concurrency
          • Frameworks
            • Jdbc与连接池
            • Rxjava基础
            • Spring框架基础
          • Sugar&skill
        • Tool
          • Docker
            • Docker basis
            • Kubernetes play
          • Git
            • Git basic
          • Vim
            • Vim advance
      • Cs
        • Imp
          • Lru
          • Index
    • Snippets
      • Jpa和spring系列注解表
      • Java与oracle数据库各种操作
      • Maven初始化template
      • Nginx配置
      • Nginx反代后配置自动ssl续签
      • 终端033颜色
    • Ways
      • Java ways 01
      • Interview
        • Question
        • Requirements
      • Leetcode101
        • Acwing
          • Index
          • 背包问题
        • Explores
        • Solutions
          • Algorithms
            • Index
          • Concurrency
            • Index
          • Shell
            • Index
          • Sql
            • Index
  • Leecode
    • 牛客
      • 剑指offer
  • Play
    • Youtube离线下载
  • Python basic notes
    • Python days
Powered by GitBook
On this page
  • Docker
  • Installation
  • Images,Containers,and Ports
  • Volumes - Host adn Container
  • Building Images
  • Resources

Was this helpful?

  1. Java ways
  2. 101
  3. Basis
  4. Tool
  5. Docker

Docker basis

PreviousDockerNextKubernetes play

Last updated 4 years ago

Was this helpful?

   Author: Gentleman.Hu
   Create Time: 2020-11-01 10:47:02
   Modified by: Gentleman.Hu
   Modified time: 2020-11-02 11:23:19
   Email: justfeelingme@gmail.com
   Home: https://crushing.xyz
   Description: Docker new one

Docker

Installation

对应系统下载.

安装好,在托盘图标可以看到状态,启动成功

  • 查看版本

Images,Containers,and Ports

docker image COMMAND

  • show containers

docker image ps

  • 基本命令平时就查看,其他build等简单使用

docker container COMMAND

  • show containers

docker container ls [-a] 显示全部(包含未运行的)

image就是镜像,静态的,通过image可以生成container

docker pull COMMAND

拉取image

docker run COMMAND

docker run --name name -d imagename

通过image创建container并运行 -d,dettach

  • 开放端口

docker run -p outer:inner imagename

outer: 外部端口 inner: 内部端口

比如 8080:80 ,外部宿主计算机端口映射到docker内部80端口

  • 开放多个端口

-p 8080:80 -p 2222:222 -p etc...

  • 删除container

docker rm -f containername

  • 删除image

docker rmi imagename

Volumes - Host adn Container

  • share file from host

docker run --name name -v /some/folder:/usr/local/nginx/html:ro -p 8080:80 nginx:latest

  • going inside container

docker exec -it containername bash(/bin/sh)

Building Images

  • Dockerfile

FROM ubuntu:18.04
COPY . /app
RUN make /app
CMD python /app/app.py
  • docker build

  • docker push

推送到duckerhub或者其他docker仓库

  • .dockerignore

# comment
*/temp*
*/*/temp*
temp?

Rule

Behavior

# comment

Ignored.

*/temp*

Exclude files and directories whose names start with temp in any immediate subdirectory of the root. For example, the plain file /somedir/temporary.txt is excluded, as is the directory /somedir/temp.

*/*/temp*

Exclude files and directories starting with temp from any subdirectory that is two levels below the root. For example, /somedir/subdir/temporary.txt is excluded.

temp?

Exclude files and directories in the root directory whose names are a one-character extension of temp. For example, /tempa and /tempb are excluded.

此文件忽略通过规则定义的文件 然而,往往忽略的,需要在dockerfile中重新RUN来在部署时候生成module等

  • Alpine

很精简的,体积很小.适合集成docker中

FROM alpine:3.7
RUN apk add --no-cache mysql-client
ENTRYPOINT ["mysql"]

一个使用例子 36.8MB

Resources

Reference
Reference
official
docker_alpine
https://hub.docker.com/_/alpine
dockerignore
get-started