码迷,mamicode.com
首页 > 其他好文 > 详细

docker简记

时间:2018-05-19 18:26:42      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:用户   java_opts   output   following   free   hello   mat   后台进程   contain   

技术分享图片

 

首先需要明确上图的几个概念:

Docker daemon(Docker守护进程)

Docker daemon是运行在宿主机的后台进程,可以通过Client与之通信;

Client(Docker客户端)

Docker客户端用于与用户交互,可以接受用户命令和配置标识,并与Docker daemon通信。docker build等都是Docker的相关命令;

Images(Docker镜像)

Docker镜像是一个只读模板,它是一个创建Docker容器的命令集合,通常一个镜像会涵盖其他镜像,并且会有自身的一些定制。它和系统安装ISO程序有点儿像,使用Docker镜像可以创建Docker容器,Docker容器则可以运行我们配置的程序;

Container(容器)

容器是镜像的可运行实力,一个镜像可以创建多个容器。

Registry

Docker Registry是一个集中存储与分发镜像的服务。一个Docker Registry可包含多个Docker仓库,每个仓库可包含多个镜像标签每个标签对应一个Docker镜像。与Maven仓库类比,Docker Registry可以看做Maven仓库,Docker Repository可以看做某类库,tag可以看做类库版本号,repository+tag可以唯一确定一个镜像

Docker Registry可分为公有和私有,默认为官方的共有的Docker Hub。


 

安装

1.安装docker

sudo apt install docker.io

2.查看docker信息

sudo docker info

3.docker的HelloWorld

sudo docker run hello-world

Unable to find image ‘hello-world:latest‘ locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

 


 

Dockerfile常用指令

FROM

ENV

ADD

RUN

EXPOSE

CMD

FROM tomcat:9-jre9

ENV TOMCAT_HOME /usr/local/tomcat
ENV DIR_WEBAPP /usr/local/tomcat/webapps 

ADD web-demo.war $DIR_WEBAPP/web-demo.war 

EXPOSE 80 443

CMD ["catalina.sh", "run"]

 


 

docker常用命令

docker info

docker images

docker build -t repository:tag DockerfilePath

docker run -it -p 80:80 -v /data:/data -d nginx:latest

ps: tomcat有时启动会阻塞在产生随机数的地方,需要在catalina.sh中加入JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom"

https://docs.docker.com/engine/docker-overview/#the-docker-platform

docker简记

标签:用户   java_opts   output   following   free   hello   mat   后台进程   contain   

原文地址:https://www.cnblogs.com/holoyong/p/9016059.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!