侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

Docker的第一次亲密接触

2023-12-12 星期二 / 0 评论 / 0 点赞 / 103 阅读 / 6655 字

Docker的第一次亲密接触[TOC]好奇宝宝三千问什么是docker,为什么要使用dockerDocker和Vagrant的区别云计算和Docker的关联趋势:我们为什么要学习储备Docker知识入

Docker的第一次亲密接触

[TOC]

好奇宝宝三千问

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

入手:看官方文档

  • 教程:Getting Started with Docker for Mac
  • 下载:猛击这里,虽然教程里已经有了
  • 按照教程一步一步,安装工具,启动,起第一个容器“hello,world!”,再起一个容器nginx....

为什么是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 ttys000ChinaDreams:~ kangcunhua$ docer info-bash: docer: command not foundChinaDreams:~ kangcunhua$ docker infoContainers: 0 Running: 0 Paused: 0 Stopped: 0Images: 0Server Version: 1.12.1Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 0 Dirperm1 Supported: trueLogging Driver: json-fileCgroup Driver: cgroupfsPlugins: Volume: local Network: null host bridge overlaySwarm: inactiveRuntimes: runcDefault Runtime: runcSecurity Options: seccompKernel Version: 4.4.20-mobyOperating System: Alpine Linux v3.4OSType: linuxArchitecture: x86_64CPUs: 2Total Memory: 1.953 GiBName: mobyID: QEBV:OQVX:UCAL:JSC6:L3HD:JR2F:3573:QNQO:OUQM:XX2E:2WFC:D6ASDocker Root Dir: /var/lib/dockerDebug Mode (client): falseDebug Mode (server): true File Descriptors: 16 Goroutines: 27 System Time: 2016-11-03T14:52:53.397995674Z EventsListeners: 1No Proxy: *.local, 169.254/16Registry: https://index.docker.io/v1/Insecure Registries: 127.0.0.0/8ChinaDreams:~ kangcunhua$ docker --versionDocker version 1.12.1, build 6f9534cChinaDreams:~ kangcunhua$ docker-compose --versiondocker-compose version 1.8.0, build f3628c7ChinaDreams:~ kangcunhua$ docker-machine --versiondocker-machine version 0.8.1, build 41b3b25ChinaDreams:~ kangcunhua$ docker psCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMESChinaDreams:~ kangcunhua$ docker run hello-worldUnable to find image 'hello-world:latest' locallylatest: Pulling from library/hello-worldc04b14da8d14: Pull complete Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9Status: Downloaded newer image for hello-world:latestHello 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 bashShare images, automate workflows, and more with a free Docker Hub account: https://hub.docker.comFor more examples and ideas, visit: https://docs.docker.com/engine/userguide/ChinaDreams:~ kangcunhua$ docker run -d -p 80:80 --name webserver nginxUnable to find image 'nginx:latest' locallylatest: Pulling from library/nginx43c265008fae: Pull complete e4c030a565b1: Pull complete 685b7631c1ce: Pull complete Digest: sha256:dedbce721065b2bcfae35d2b0690857bb6c3b4b7dd48bfe7fc7b53693731beffStatus: Downloaded newer image for nginx:latest30a5b7c29d54c91e0107ba305601dc019bd2dab4251dd250b37d76c41fe4062fChinaDreams:~ kangcunhua$ 

继续,第二天继续学习

ChinaDreams:~ kangcunhua$ docker psCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMESChinaDreams:~ kangcunhua$ docker run -d -p 80:80 --name webserver nginxdocker: 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 psCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMESChinaDreams:~ kangcunhua$ docker stop webserverwebserverChinaDreams:~ kangcunhua$ docker psCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMESChinaDreams:~ kangcunhua$ docker start webserverwebserverChinaDreams:~ kangcunhua$ docker psCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                         NAMES30a5b7c29d54        nginx               "nginx -g 'daemon off"   16 hours ago        Up 4 seconds        0.0.0.0:80->80/tcp, 443/tcp   webserverChinaDreams:~ kangcunhua$ docker stop webserverwebserverChinaDreams:~ kangcunhua$ docker psCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMESChinaDreams:~ kangcunhua$ docker rm -f webserverwebserverChinaDreams:~ kangcunhua$ docker psCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMESChinaDreams:~ kangcunhua$ docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZEnginx               latest              e43d811ce2f4        13 days ago         181.5 MBhello-world         latest              c54a2cc56cbb        4 months ago        1.848 kBChinaDreams:~ 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

广告 广告

评论区