Docker的第一次亲密接触
Docker的第一次亲密接触
蛮大人 发表于1年前
Docker的第一次亲密接触
  • 发表于 1年前
  • 阅读 408
  • 收藏 2
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

摘要: Docker的第一次亲密接触,看官方教程的部分练习日志

Docker的第一次亲密接触

[TOC]

好奇宝宝三千问

  • 什么是docker,为什么要使用docker
  • Docker和Vagrant的区别
  • 云计算和Docker的关联
  • 趋势:我们为什么要学习储备Docker知识

入手:看官方文档

为什么是docker-for-mac

最好的起步工具: Docker for Mac [^mac下使用docker-for-mac代替docker-toolbox],当然也有docker-for-windows,windows用户看这里

看看我的第一次Docker之旅吧

看到nginx运行起来的一刹那,被震撼了:传统运维的那些繁琐的准备环境、安装、配置、调试才可能跑起来一个勉强能用的Web server,有了docker,只需要一条命令。不学习,要被淘汰啊!

Last login: Thu Nov  3 10:34:08 on ttys000
ChinaDreams:~ kangcunhua$ docer info
-bash: docer: command not found
ChinaDreams:~ kangcunhua$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.20-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.953 GiB
Name: moby
ID: QEBV:OQVX:UCAL:JSC6:L3HD:JR2F:3573:QNQO:OUQM:XX2E:2WFC:D6AS
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 16
 Goroutines: 27
 System Time: 2016-11-03T14:52:53.397995674Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Insecure Registries:
 127.0.0.0/8
ChinaDreams:~ kangcunhua$ docker --version
Docker version 1.12.1, build 6f9534c
ChinaDreams:~ kangcunhua$ docker-compose --version
docker-compose version 1.8.0, build f3628c7
ChinaDreams:~ kangcunhua$ docker-machine --version
docker-machine version 0.8.1, build 41b3b25
ChinaDreams:~ kangcunhua$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ChinaDreams:~ kangcunhua$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
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.
 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 Hub account:
 https://hub.docker.com

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

ChinaDreams:~ kangcunhua$ docker run -d -p 80:80 --name webserver nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
43c265008fae: Pull complete 
e4c030a565b1: Pull complete 
685b7631c1ce: Pull complete 
Digest: sha256:dedbce721065b2bcfae35d2b0690857bb6c3b4b7dd48bfe7fc7b53693731beff
Status: Downloaded newer image for nginx:latest
30a5b7c29d54c91e0107ba305601dc019bd2dab4251dd250b37d76c41fe4062f
ChinaDreams:~ kangcunhua$ 

继续,第二天继续学习

ChinaDreams:~ kangcunhua$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ChinaDreams:~ kangcunhua$ docker run -d -p 80:80 --name webserver nginx
docker: Error response from daemon: Conflict. The name "/webserver" is already in use by container 30a5b7c29d54c91e0107ba305601dc019bd2dab4251dd250b37d76c41fe4062f. You have to remove (or rename) that container to be able to reuse that name..
See 'docker run --help'.
ChinaDreams:~ kangcunhua$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ChinaDreams:~ kangcunhua$ docker stop webserver
webserver
ChinaDreams:~ kangcunhua$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ChinaDreams:~ kangcunhua$ docker start webserver
webserver
ChinaDreams:~ kangcunhua$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                         NAMES
30a5b7c29d54        nginx               "nginx -g 'daemon off"   16 hours ago        Up 4 seconds        0.0.0.0:80->80/tcp, 443/tcp   webserver
ChinaDreams:~ kangcunhua$ docker stop webserver
webserver
ChinaDreams:~ kangcunhua$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ChinaDreams:~ kangcunhua$ docker rm -f webserver
webserver
ChinaDreams:~ kangcunhua$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ChinaDreams:~ kangcunhua$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              e43d811ce2f4        13 days ago         181.5 MB
hello-world         latest              c54a2cc56cbb        4 months ago        1.848 kB
ChinaDreams:~ kangcunhua$ 

[^mac下使用docker-for-mac代替docker-toolbox]: 为什么使用Docker for Mac:启动时不需要再使用dokcer-machine设定启动的默认的环境,省去了使用virtualbox的过程;享受和在linux下使用docker一样的体验. 总之,新工具更方便!mac下启动docker的工具发展:最开始使用boot2docker,,再到Docker Toolbox,最近新出的 Docker for Mac ;更多信息移步这里:mac下使用docker-for-mac代替docker-toolbox

共有 人打赏支持
蛮大人
粉丝 33
博文 20
码字总数 38023
×
蛮大人
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: