Chinaunix首页 | 论坛 | 博客
  • 博客访问: 279553
  • 博文数量: 73
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 452
  • 用 户 组: 普通用户
  • 注册时间: 2014-09-22 17:07
个人简介

心态决定命运

文章分类

全部博文(73)

文章存档

2017年(21)

2016年(27)

2015年(21)

2014年(4)

我的朋友

分类: 系统运维

2016-03-20 19:40:45

系统:centos7
内核版本:inux localhost.localdomain 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
参考:

1. docker 安装

点击(此处)折叠或打开

  1. curl -fsSL https://get.docker.com/ | sh
  2. sudo service docker start
  3. ps -ef |grep docker
    root      11882      1  1 02:35 ?        00:00:38 /usr/bin/docker daemon -H fd://
    lujj      16828  10761  0 03:28 pts/0    00:00:00 grep --color=auto docker
  4. sudo docker run hello-world
2. 镜像和容器
    Docker Engine provides the core Docker technology that enables images and containers. As the last step in your installation, you ran the Engine docker run hello-world command. With this one command, you completed the core tasks to using Engine. The command you ran had three parts.
  

   A container is a stripped-to-basics version of a Linux operating system. An image is software you load into a container. When you ran the command, the Engine software:

  • checked to see if you had the hello-world software image
  • downloaded the image from the Docker Hub (more about the hub later)
  • loaded the image into the container and “ran” it

   A Docker image, though, is capable of much more. An image can start software as complex as a database, wait for you (or someone else) to add data, store the data for later use, and then wait for the next person.

Who built the hello-world software image though? In this case, Docker did but anyone can. Docker Engine lets people (or companies) create and share software through Docker images. Using Docker Engine, you don’t have to worry about whether your computer can run the software in a Docker image — a Docker container can always run it.




3.  查找运行whalesay 镜像   
  docker run docker/whalesay cowsay boo-boo
4. 创建自己的镜像
 

点击(此处)折叠或打开

  1. mkdir ~/dockerbuild
  2. cd ~/dockerbuild
  3. touch Dockerfile
  4. cat >Dockerfile1 < FROM docker/whalesay:latest
    RUN apt-get -y update && apt-get install -y fortunes
    CMD /usr/games/fortune -a | cowsay
    EOF
  5. docker build -t docker-whale .
  6. docker images
    REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
    docker-whale                   latest              8dcf3d51d4dc        2 hours ago         255.7 MB
    hello-world                    latest              690ed74de00f        5 months ago        960 B
    docker/whalesay                latest              6b362a9f73eb        9 months ago        247 MB
  7. docker run docker-whale
  docker-whale 新建镜像的名称

5. Create a Docker Hub Account & repository
6. 标记、推送、拉取镜像
 

点击(此处)折叠或打开

  1. docker images
  2. REPOSITORY   TAG     IMAGE ID       CREATED SIZE
  3. docker-whale latest 8dcf3d51d4dc 2 hours ago 255.7 MB
  4. hello-world latest 690ed74de00f 5 months ago 960 B
  5. docker/whalesay latest 6b362a9f73eb 9 months ago 247 MB
  8dcf3d51d4dc 镜像ID
  1)使用镜像ID 和docker tag 命令 标记镜像
 
  docker tag 8dcf3d51d4dc  docker27014/docker-whale:latest
  docker tag imageID hubAccountID/imageName:tags

点击(此处)折叠或打开

  1. docker images
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. docker-whale latest 8dcf3d51d4dc 2 hours ago 255.7 MB
  4. docker27014/docker-whale latest 8dcf3d51d4dc 2 hours ago 255.7 MB
  5. hello-world latest 690ed74de00f 5 months ago 960 B
  6. docker/whalesay latest 6b362a9f73eb 9 months ago 247 MB
  2)命令行登录docker hub
   

点击(此处)折叠或打开

  1. docker login --username=yourhubusername --email=youremail@company.com
  3) 推送镜像

点击(此处)折叠或打开

  1. docker push docker27014/docker-whale
  推送成功后,删除本地镜像
 

点击(此处)折叠或打开

  1. docker rmi -f 8dcf3d51d4dc
  2. docker rmi -f docker-whale
  3) 从本人资源库拉取镜像

点击(此处)折叠或打开

  1. docker run docker27014/docker-whale







阅读(1066) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~