第一步:
进入下图的文件夹中
然后执行以下的说明执行步骤
 
第二步:
开发环境dockerfile
BUILD
docker build -t silentmoon/centos7:devel -f centos7_ssh_devel .
咖啡时间,请保持网络连接,如果网速慢的话,就别继续往下看了。
RUN
docker run -d -P --name devel_centos7_ssh -h develop silentmoon/centos7:devel
没有报错就说明镜像启动正常 docker ps 看一下是否存在
ACCESS
  • User/Password: work/qwe!@#bnm root/4man49a52e27
  • Method of ssh
ssh work@127.0.0.1 -p32768一般情况是32768,docker ps查看一下
  • Method of docker
docker exec -it 9e34e8ff45ea bash container id 需要自己查看
  • Method of Shell
ln -s `pwd`/devel ~/bin/devel chmod 755 ~/bin/devel devel
Work Directory Structure
cd ~ mkdir app mkdir env mkdir src mkdir tmp mkdir tar mkdir bin
Nginx Install
GET
cd ~/src wget http://www.oursdata.com/misc/nginx-1.10.2.tar.gz tar -zxvf nginx-1.10.2
Configure & Make
cd ~/src/nginx-1.10.2 ./configure --prefix=/home/work/env/nginx --sbin-path=/home/work/env/nginx/sbin/nginx --conf-path=/home/work/env/nginx/conf/nginx.conf --error-log-path=/home/work/env/nginx/error-log --pid-path=/home/work/env/nginx/run/nginx.pid --lock-path=/home/work/env/nginx/lock/nginx.lock --user=work --group=work make && make install
补充:默认下nginx是没有启动的,需要进入sbin文件下,./nginx 启动    ./nginx -s reload 重新加载nginx  
 
 
PHP Install
GET
cd ~/src wget http://www.oursdata.com/misc/php-5.6.29.tar.gz tar -zxvf php-5.6.29.tar.gz
Configure & Make
cd ~/src/php-5.6.29 ./configure --prefix=/home/work/env/php --with-config-file-path=/home/work/env/php/etc --with-mysqli --with-pdo-mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype make && make install
 
补充:etc文件下是没有php.ini文件,需要到80服务器上复制一个配置文件过来且可以同时把80服务器上的ext下扩展文件也拷贝过来,然后去sbin文件执行
./php-fpm -c ../etc/php.ini 
 
 
设置nginx配置文件
再nginx的结尾处nginx.conf
加上 include hosts/*.conf;
然后再conf文件夹下新建一个hosts文件夹,在hosts文件新建
配置文件如:tianjian.conf
server {
    listen       80;
    index index.php;
    root /home/work/app/tj-bdaas/src/tj-bdaas/src/web/web;     
    server_name  tianjian.loc.cn;                                             
     location / {
                   index index.php;
                   if (!-e $request_filename){
                      rewrite ^/(.*) /index.php last;                 }
          }
 
    location ~ \.php$
    {
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
配置文件完成后,进入sbin文件下   执行  ./nginx -s reload 
最后去 vim /etc/hosts 文件下配置自己的虚拟域名,如下图
 
 
 
第三步
此时容器里面的nginx和php 已经安装完成,现在可以把这个容易做成一个镜像
docker commit -m "change somth" -a "somebody info" container_id(docker ps -a获取id) 新镜像名字        //docker使用现有容器生成新的镜像
这样就会生成一个新的镜像
通过docker images
就会看到自己制作的镜像
 
第四步 把自己镜像再放到容器里面
docker制作镜像
docker run -p 127.0.0.1:80:80 -p 127.0.0.1:32766:22 -d -v /usr/local/var/www/:/home/work/app tang/centos_devel:latest
docker run -p 127.0.0.1:80:80  -d -P --name devel_centos7_ssh -h develop  -v /Users/zhangyougang/app:/home/work/app silentmoon/centos7:devel
 
这样就大功告成了!
 
 
如果数据库为mongodb库,需要安装下mongo  数据库
docker pull mongo      //由于网络原因,可能会报错,多pull几次就可以
docker pull mongo -express     //由于网络原因,可能会报错,多pull几次就可以
 
 
创建mongoldb容器
 
docker run —name mongo -p 27017:27017 -d mongo
 
创建mongo-expres容器
 
docker run —link mongo:mongo —name mongo-express -p 8081:8081 -d mongo-express
 
 
sudo docker inspect mongo  查看mongo的ip地址
 
 
进入容器
docker exec -it mongo名字 bin/bash

dockerfile创建镜像及容器的更多相关文章

  1. docker常用命令、镜像命令、容器命令、数据卷,使用dockerFile创建镜像,dockefile的语法规则。

    一.docker常用命令? 1. 常用帮助命令 1.1 docker的信息以及版本号 /* docker info 查看docker的信息 images2 docker本身就是一个镜像. docker ...

  2. docker——Dockerfile创建镜像

    写在前面: 继续docker的学习,昨天用docker成功跑了tomcat,但是在centos中镜像跑的容器手动装jdk和tomcat,今天学习用Dockerfile创建镜像,并在上面搭建java环境 ...

  3. docker学习笔记6:利用dockerfile创建镜像介绍(生成简单web服务器镜像)

    本文介绍如何利用dockerfile来创建镜像.下面介绍具体的操作过程: 一.创建构建环境 操作示例如下: xxx@ubuntu:~$ pwd /home/xxx xxx@ubuntu:~$ mkdi ...

  4. Dockerfile创建镜像

    Dockerfile是一个文本格式的配置文件,用户可以使用Dockerfile来快速创建自定义的镜像. Dockerfile由一行行命令语句组成,并且支持易#开头的注释行. 一般而言Dockerfil ...

  5. 【云计算】Dockerfile、镜像、容器快速入门

    Dockerfile.镜像.容器快速入门 1.1.Dockerfile书写示例 Dockerfile可以用来生成Docker镜像,它明确的定义了Image的生成过程.虽然直接修改容器也可以提交生成镜像 ...

  6. 如何用Dockerfile创建镜像

    本文原创,原文地址为:http://www.cnblogs.com/fengzheng/p/5181222.html 创建镜像的目的 首先说DockerHub或其它一些镜像仓库已经提供了够多的镜像,有 ...

  7. 使用Dockerfile创建镜像

    Dockerfile是一个文本格式的配置文件,用户可以使用Dockerfile来快速创建自定义的镜像. 一.基本结构 Dockerfile由一行行命令语句组成,并且支持以#开头的注释行. 一般而言,D ...

  8. [转]Docker基础-使用Dockerfile创建镜像

    本文转自:https://www.cnblogs.com/jie-fang/p/7927643.html 1.基本结构 Dockerfile由一行行命令语句组成,并支持以#开头的注释行.例如: # T ...

  9. Docker基础-使用Dockerfile创建镜像

    1.基本结构 Dockerfile由一行行命令语句组成,并支持以#开头的注释行.例如: # This dockerfile uses the ubuntu image # VERSION 2 - ED ...

随机推荐

  1. jmeter提取正则表达式中所有关联值-----我想获取所有的ID

    [{ "ID": 1, "Name": "张三" }, { "ID": 2, "Name": &qu ...

  2. C# QR二维码DEMO

    QR二维码 二维码的一种 相关类库 ThoughtWorks.QRCode 第三方类库 DEMO功能 Encode 生成二维码图片 Encoding 编码 Correction Level 等级 Ve ...

  3. topcoder srm 738 div1 FindThePerfectTriangle(枚举)

    Problem Statement      You are given the ints perimeter and area. Your task is to find a triangle wi ...

  4. git gitosis 添加项目

    example: 1, user@my-test:~/perl_src$ git inituser@my-test:~/perl_src$ git add .user@my-test:~/perl_s ...

  5. 【CF248E】Piglet's Birthday(动态规划)

    [CF248E]Piglet's Birthday(动态规划) 题面 洛谷 CodeForces 翻译: 给定\(n\)个货架,初始时每个上面有\(a[i]\)个蜜罐. 有\(q\)次操作,每次操作形 ...

  6. java线程池赏析

    1.线程池的顶级接口(Executor) 线程池的顶级接口(jdk > 1.5).仅仅定义了方法execute(Runnable). 该方法接收一个Runnable实例,用来执行一个任务,该任务 ...

  7. MySQL 第二篇:库操作

    一 系统数据库 information_schema: 虚拟库,不占用磁盘空间,存储的是数据库启动后的一些参数,如用户表信息.列信息.权限信息.字符信息等performance_schema: MyS ...

  8. linux下tar.gz、tar、bz2、zip等解压缩、压缩命令

    转至:http://www.jb51.net/LINUXjishu/43356.html 说明:Linux下最常用的打包程序就是tar了,使用tar程序打出来的包我们常称为tar包,tar包文件的命令 ...

  9. HOJ 13102 Super Shuttle (圆的反演变换)

    HOJ 13102 Super Shuttle 链接:http://49.123.82.55/online/?action=problem&type=show&id=13102 题意: ...

  10. Go_18: Golang 中三种读取文件发放性能对比

    Golang 中读取文件大概有三种方法,分别为: 1. 通过原生态 io 包中的 read 方法进行读取 2. 通过 io/ioutil 包提供的 read 方法进行读取 3. 通过 bufio 包提 ...