# Docker
# Flag
- https://github.com/docker (opens new window)
- https://github.com/boot2docker (opens new window)
- Docker及图形化管理UI Portainer的搭建 (opens new window)
- 利用Docker实现后台项目模板化配置部署 (opens new window)
- Docker进阶实用命令 (opens new window)
- https://sleele.com/category/docker/ (opens new window)
- https://docs.microsoft.com/zh-cn/virtualization (opens new window)
- https://developer.ibm.com/zh/technologies/containers (opens new window)
- 随笔分类 - Docker (opens new window)
- https://kany.me/tags/docker (opens new window)
其他容器技术
- OCI开放容器标准 https://github.com/opencontainers (opens new window)
- 云原生技术图谱 https://github.com/cncf/landscape (opens new window)
- OCI,CRI,CRI-O,Containerd 名词解释 (opens new window)
- 从开发者的角度比较Kubernetes和Cloud Foundry (opens new window)
- https://github.com/kubernetes (opens new window)
- Kubernetes的软件包管理器 https://github.com/helm (opens new window)
- https://github.com/lensapp/lens (opens new window)
- https://github.com/jenkins-x (opens new window)
- https://github.com/kinvolk (opens new window)
- https://github.com/dapr (opens new window)
- https://github.com/dokku (opens new window)
- https://github.com/cloudfoundry (opens new window)
- cloud-foundry 的动态 - SegmentFault 思否 (opens new window)
- https://www.terraform.io (opens new window)
- https://github.com/rancher/rancher (opens new window)
- https://github.com/mesosphere/marathon (opens new window)
- Ansible
- Packer
- 谷歌、IBM、微软、Pivotal、SAP、SUSE、Swisscom、GE
- DevOps
- https://github.com/openzfs/zfs (opens new window)
- https://github.com/wekan/wekan (opens new window)
- https://github.com/systemd (opens new window)
- https://github.com/coreos (opens new window)
- Linux Container https://github.com/lxc/lxc (opens new window)
- podman https://github.com/containers (opens new window)
- https://github.com/containerd/containerd (opens new window)
- https://github.com/moby/moby (opens new window)
- https://github.com/coreos (opens new window)
- https://github.com/cri-o/cri-o (opens new window)
- https://github.com/kata-containers (opens new window)
- https://github.com/chaosblade-io/chaosblade (opens new window)
- https://github.com/alibaba/pouch (opens new window)
- https://github.com/singularity/singularity (opens new window)
- https://github.com/apache/mesos (opens new window)
- https://github.com/OpenVZ (opens new window)
- https://github.com/firecracker-microvm/firecracker (opens new window)
Docker搭建私有仓库
- 企业级Registry服务器 https://github.com/goharbor/harbor (opens new window)
- Docker 私有仓库搭建 (opens new window)
- 从零搭建docker私有仓库 (opens new window)
# 仓库镜像
- Docker官方映像 https://github.com/docker-library (opens new window)
- https://hub.docker.com (opens new window)
- https://hub.daocloud.io (opens new window)
以下镜像地址需要直接配置在docker中,不能通过浏览器访问
- 阿里云 https://cr.console.aliyun.com (opens new window)
- ustc中国科技大学 https://docker.mirrors.ustc.edu.cn (opens new window)
- 网易 http://hub-mirror.c.163.com (opens new window)
- Docker 官方中国区 https://registry.docker-cn.com (opens new window)
- Azure 中国镜像 https://dockerhub.azk8s.cn (opens new window)
- 七牛云加速器 https://reg-mirror.qiniu.com (opens new window)
- 腾讯云 https://mirror.ccs.tencentyun.com (opens new window)
# 容器服务器
- https://console.cloud.google.com/appengine (opens new window)
- https://cloud.google.com/container-registry (opens new window)
- https://cloud.ibm.com/cloudfoundry/overview (opens new window)
- https://cloud.ibm.com/shell (opens new window)
- http://cli.cloudfoundry.org/zh-Hans/cf (opens new window)
- 使用ssh部署代码是错误的。正确做法是先进入
ibmcloud target --cf
使用ibmcloud cf push
命令ibmcloud cf push 容器名 -b php_buildpack -m 256M -c "ls && ce /home"
- 在push的代码目录里创建.bp-config配置文件,可以修改app的启动行为、可以修改
php.ini
等。否则你的container和其他服务做链接时就会被刷回原始状态。 - 10天是指开发行为,必须是类似于
ibm cloud cf restart
或者cf push
这样的行为,可以用纯shell脚本实现。
- https://github.com/codefresh-io (opens new window)
- https://github.com/kubesail (opens new window)
- https://azure.microsoft.com/zh-cn/services/devops/pipelines (opens new window)
- https://github.com/containerum (opens new window)
- 樱花 https://arukas.io (opens new window)
- Oracle https://app.wercker.com (opens new window)
# Docker命令
# 退出docker容器
# 如果容器内部没有任何程序运行, 一旦执行exit, 退出容器时, 容器将结束运行
exit
# 查看运行中的容器
docker ps
# 查看全部的容器, 包括运行中和已停止运行的容器
docker ps -a
# 通过容器名称删除已经停止运行的容器(test-centos为docker run命令中给容器的命名)
docker rm test-centos
# 通过容器ID删除已经停止运行的容器,与上面的命令效果一样, 060e是containerID的前4位
docker rm 060e
# 强制删除状态为Up, 正在运行中的容器
docker rm -f test-centos
# Docker compose
- Docker Compose概述 (opens new window)
- Compose文件参考 (opens new window)
- docker-compose.yml 配置文件编写详解 (opens new window)
- Docker Compose 详解 (opens new window)
- Docker Compose 配置文件详解 (opens new window)
- docker run 和 docker-compose 配置挂载 Volume 并运行 nginx (opens new window)
Compose 文件是一个 YAML , 主要定义了
services
,networks
和volumes
,其默认路径是./docker-compose.yml
service
定义包含了应用与每个容器的配置,很像给docker run
传参,同样,network
和volume
对于docker network create
和docker volume create
也类似。
像在 Dockerfile (eg:
CMD
,EXPOSE
,VOLUME
,ENV
)可以使用的选项也可以在docker run
参数中使用, 这样在docker-compose.yml
里就不需要再次指定了。
docker-compose.yml
里可以使用环境变量,类似Bash
格式${VARIABLE}
composer
文件格式有两种版本:version 1
: 已经废弃, 不支持volumes
和networks
,默认version key
是省略的。version 2
: 推荐的格式,目前是最新的,需要通过version '2'
指定。
ports
暴露端口。既可以是
HOST:CONTAINER
,也可以只用容器端口(host端口会随机选取)。 当以HOST:CONTAINER
的形式映射端口的时候,当容器的端口低于60的时候可能会遇到错误, 因为YAML会解析 xx:yy 数字为60。 基于这个原因,我们推荐明确指定端口映射用字符串的形式。
volumes
挂载指定的路径或者
named volumes
, 可以在主机上指定一个路径 HOST:CONTAINER ,或者一个可访问的 HOST:CONTAINER:ro 。
# Dockerfile
- Dockerfile参考 (opens new window)
- 编写Dockerfile的最佳实践 (opens new window)
- Dockerfile 基本命令详解 (opens new window)
- 创建
Dockerfile
文件
vi Dockerfile
- 添加内容
# 使用的基础镜像
FROM centos:7
# 作者信息
MAINTAINER bajins "claer@bajins.com"
# 创建目录
RUN mkdir -p /data/java/jdk1.7.0_80
# 把当前目录下的jdk文件夹添加到镜像
ADD jdk1.7.0_80 /data/java/jdk1.7.0_80
# 创建tomcat目录
RUN mkdir -p /data/java/tomcat-8080
# 把当前目录下的tomcat文件夹添加到镜像
ADD tomcat-8080 /data/java/tomcat-8080
# 添加环境变量
ENV JAVA_HOME /data/java/jdk1.7.0_80
ENV CATALINA_HOME /data/java/tomcat-8080
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin
# 暴露容器端口
EXPOSE 8080
EXPOSE 8090
# 启动时运行tomcat
CMD ["/data/java/tomcat-8080/bin/catalina.sh","run"]
FROM centos:7
#安装wget工具
RUN yum -y install wget
#下载并且安装jdk设置环境变量
COPY jdk-8u201-linux-x64.rpm jdk-8u201-linux-x64.rpm
RUN rpm -ivh jdk-8u201-linux-x64.rpm
ENV JAVA_HOME /usr/java/latest/
ENV PATH=$JAVA_HOME/bin:$PATH
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
RUN rm -rf jdk-8u201-linux-x64.rpm
#时区中文等处理
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo 'Asia/Shanghai' >/etc/timezone
RUN yum -y install kde-l10n-Chinese
#配置显示中文
RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
ENV LC_ALL zh_CN.utf8
RUN echo "export LC_ALL=zh_CN.utf8" >> /etc/profile