1.7 根据1.6创建的镜像,生成nginx容器

 一、环境准备

1、已创建好数据库容器,并开启。

2、已经按1.6章节要求完成nginx/nginx:v2版本的镜像创建。

如下图:

[root@itpux nginx]# docker ps
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS                    NAMES
2f049fa02789        centos/mysql5.7:v6   "/bin/bash"         2 days ago          Up 43 minutes       0.0.0.0:3306->3306/tcp   mysqldb
[root@itpux nginx]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
nginx/nginx                 v2                  58fa4819c343        20 minutes ago      512 MB
backend                     1.0                 56f26ab0f8bd        39 hours ago        715 MB
centos/mysql5.7             v6                  35dee3f4071b        2 days ago          4.28 GB
centos/mysql5.7             v4                  5874f49a05b6        2 days ago          419 MB
docker.io/nginx             latest              e81eb098537d        7 days ago          109 MB
docker.io/centos            latest              75835a67d134        6 weeks ago         200 MB
docker.io/centos            v1                  75835a67d134        6 weeks ago         200 MB
10.124.133.178/devops/jdk   1.0                 904b9373e5d6        8 months ago        715 MB
[root@itpux nginx]# 

 

 

二、创建容器,并进入创建后的容器

1、映射的端口一定要与nginx脚本中开放的端口一致,如8080

2、访问的后台容器名称一定要一致,如jdkdb.

 

docker run -dit --name nginx --privileged=true --restart=always --link=jdkdb:jdkdb --link=mysqldb:mysqldb -p 8080:8080 -v /docker/nginx/www:/docker/nginx/www:rw -v /docker/nginx/logs/:/docker/nginx/logs/:rw -v /docker/nginx/app/conf_start/:/docker/nginx/app/conf_start/:rw -h nginxserver nginx/nginx:v2

 

三、进行安装

进入安装程序目录

[root@nginxserver nginx-1.12.2]# pwd
/docker/nginx/nginx-1.12.2
[root@nginxserver nginx-1.12.2]# ll
total 736
-rwxrwxr-x 1 nginx nginx 278202 Oct 17  2017 CHANGES
-rwxrwxr-x 1 nginx nginx 423948 Oct 17  2017 CHANGES.ru
-rwxrwxr-x 1 nginx nginx   1397 Oct 17  2017 LICENSE
-rwxrwxr-x 1 nginx nginx    375 Nov 24 09:18 Makefile
-rwxrwxr-x 1 nginx nginx     49 Oct 17  2017 README
drwxrwxr-x 6 nginx nginx   4096 Nov 23 15:26 auto
drwxrwxr-x 2 nginx nginx   4096 Nov 23 15:26 conf
-rwxrwxr-x 1 nginx nginx   2481 Oct 17  2017 configure
drwxrwxr-x 4 nginx nginx   4096 Nov 23 15:26 contrib
drwxrwxr-x 2 nginx nginx   4096 Nov 23 15:26 html
drwxrwxr-x 2 nginx nginx   4096 Nov 23 15:26 man
drwxrwxr-x 1 nginx nginx   4096 Nov 24 09:21 objs
drwxrwxr-x 9 nginx nginx   4096 Nov 23 15:26 src
[root@nginxserver nginx-1.12.2]# 

 

 1、安装nginx

./configure --prefix=/docker/nginx/app --sbin-path=/docker/nginx/app/nginx --conf-path=/docker/nginx/app/conf_start/nginx.conf --pid-path=/docker/nginx/app/conf/nginx.pid --error-log-path=/docker/nginx/logs/nginx_error.log --http-log-path=/docker/nginx/logs/nginx_access.log --build=dockernginx --user=nginx --group=nginx --with-http_ssl_module --with-pcre=/docker/pcre-8.40 --with-zlib=/docker/zlib-1.2.11

 

 

 2、进行编译安装

[root@nginxserver nginx-1.12.2]# make
make -f objs/Makefile
make[1]: Entering directory `/docker/nginx/nginx-1.12.2'
cd /docker/pcre-8.40 \
&& if [ -f Makefile ]; then make distclean; fi \
&& CC="cc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \

 

[root@nginxserver nginx-1.12.2]# make install
make -f objs/Makefile install
make[1]: Entering directory `/docker/nginx/nginx-1.12.2'
test -d '/docker/nginx/app' || mkdir -p '/docker/nginx/app'
test -d '/docker/nginx/app' \
    || mkdir -p '/docker/nginx/app'

 

 四、上传前端代码到指定目录

 

posted on 2018-11-23 02:34  luoxf  阅读(150)  评论(0)    收藏  举报

导航