docker(1)

2017-11-26  本文已影响0人  hateko

基础

基本指令

# 脚本进入容器
  CNAME = $1
  CPID = $( docker inspect --format "{{.State.Pid}}" $CNAME)
  nscenter --target "$CPID" --mount --uts --ipc --net --pid

网络访问

数据

本地部署

Dockerfile

  1. 基础镜像信息
  2. 维护者信息
  3. 镜像操作命令
  4. 容器启动时执行指令
# This is My first Dockerfile
# Version 1.0
# Author: hateko
# Dockerfile目录 /opt/docker-file/nginx/Dockerfile 该地址同样为本地源目录

# Base images  基础镜像
From centos

# MAINTAINE   维护者信息
MAINTAINER hateko

# ADD   copy文件  这里下载好自动解压到指定路径
ADD pcre-8.37.tar.gz /usr/local/src
ADD nginx-1.9.3.tar.gz /usr/local/src

# VOLUME    目录挂载

# RUN     执行进程coding
RUN yum install -y wget gcc gcc-c++ make openssl-devel
RUN useradd -s /sbin/nologin -M www

# WORKDIR   当前容器工作目录
WORKDIR /user/local/src/nginx-1.9.3

# RUN     继续配置coding
RUN ./configure --preifix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with=pcre=/usr/local/src/pcre-8.37 && make && make install

RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf

# EXPOSE    暴露端口
ENV_PATH /usr/local/nginxsbin:$PATH
EXPOSE 80

# RUN
CMD ["nginx"]

# 执行 docker build -t nginx-file:v1  /opt/docker-file/nginx
上一篇 下一篇

猜你喜欢

热点阅读