日记(docker)

364 阅读1分钟

先说点啥吧

第一次使用docker,太牛逼的一个东西了。花了很长时间看文档,是一个好玩并懊恼的东西.....今天浅浅的了解了一下,记录了一下安装启动过程,很强的定制性(特殊性)。

今天干啥了

  • 了解docker(把下面的内容顺便同步到了 github)
  • 重温php
    今天被分到了一个php+mysql的项目

相关介绍

安装docker

官方安装教程

  1. sudo apt-get update
  2. sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
  3. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  4. sudo apt-key fingerprint 0EBFCD88
  5. sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"
  6. sudo apt-get update
  7. sudo apt-get install docker-ce
    注意
  • ce,ee区别: docker-ce(Community Edition 个人版) 和 docker-ee(Enterprise Edition 企业版)

  • 报错:
    An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release: The following signatures were invalid: KEYEXPIRED 1515625755 W: The repository 'http://ppa.launchpad.net/fcitx-team/nightly/ubuntu xenial Release' does not have a Release file. W: Failed to fetch http://repo.mongodb.org/apt/ubuntu/dists/xenial/mongodb-org/3.4/Release.gpg The following signatures were invalid: KEYEXPIRED 1515625755 E: Failed to fetch http://ppa.launchpad.net/fcitx-team/nightly/ubuntu/dists/xenial/main/binary-amd64/Packages 404 Not Found W: Some index files failed to download. They have been ignored, or old ones used instead.
    解决: overflow

  1. sudo apt-get clean
  2. sudo mv /var/lib/apt/lists /tmp
  3. sudo mkdir -p /var/lib/apt/lists/partial
  4. sudo apt-get clean
  5. sudo apt-get update

常见命令

今天使用过的几个命令   
  • 运行(默认的hello-world)
    sudo service docker start
    docker run hello-world
  • 查看版本
  • sudo docker version
  • 列出本地镜像
    sudo docker images
  • 列出容器
    sudo docker ps [options]
    -a :显示所有的容器,包括未运行的。   
    -q :静默模式,只显示容器编号。
    
  • 文档

删除默认的hello-world:

  • rm删除容器
    sudo docker rm $(sudo docker ps -aq)
  • rmi删除本地镜像:
    sudo docker rmi hello-world

导入镜像

如果在当前文件下面有一个zlms11.tar的镜像压缩文件,
而且
是为你现在手上有的项目量身订做的镜像。
  • sudo docker load < ./zlms11.tar
  • mkdir /tmp/hostinfo
  • echo "there.is.yourself.ip" > /tmp/hostinfo/controller_ip (ifconfig查询自己的ip)
  • echo "controller" > /tmp/hostinfo/controller_hostname
  • echo "172.17.0.1" > /tmp/hostinfo/vlab_ip
  • echo "172.17.0.2" > /tmp/hostinfo/zlms_ip
  • sudo docker run -it -d -v /tmp/hostinfo:/tmp/hostinfo --name zlms -p 8080:80 zlms:v12 /sbin/setup.sh (将容器的80端口映射到主机的8080端口)

最后:浏览器打开 http://localhost:8080

残留问题

本地文件修改后,需要重启docker相当麻烦...留坑明天待填......