dockerfile+ubuntu+nginx搭建web环境

准备目录

[[email protected] ~]# mkdir /usr/local/dockerfile1

该目录下准备Dockerfile文件

1 FROM ubuntu
2 MAINTAINER xbf
3 RUN sed -i ‘s/archive.ubuntu.com/mirrors.ustc.edu.cn/g‘ /etc/apt/sources.list
4 RUN apt-get update
5 RUN apt-get install -y nginx
6 COPY index.html /var/www/html
7 ENTRYPOINT ["/usr/sbin/nginx","g","daemon off;"]
8 EXPOSE 8080

解释下各行的意思

第一行:说明依赖ubuntu

第二行:作者是xbf

第三行:加速

第四行:更新一下环境

第五行:安装nginx,-y就是表示不要总是询问

第六行:拷贝服务器当前目录里的index.html到nginx里

第七行:让nginx前台运行

第八行:端口

更多Dockerfile语法

同目录下准备index.html文件

内容就一句话

What day is it today?

构建镜像

[[email protected] dockerfile1]# docker build -t xbf/hello-nginx .
Sending build context to Docker daemon 3.072 kB
Step 1/8 : FROM ubuntu
Trying to pull repository docker.io/library/ubuntu ...
latest: Pulling from docker.io/library/ubuntu
6b98dfc16071: Pull complete
4001a1209541: Pull complete
6319fc68c576: Pull complete
b24603670dc3: Pull complete
97f170c87c6f: Pull complete
Digest: sha256:5f4bdc3467537cbbe563e80db2c3ec95d548a9145d64453b06939c4592d67b6d
Status: Downloaded newer image for docker.io/ubuntu:latest
 ---> 113a43faa138
Step 2/8 : MAINTAINER xbf
 ---> Running in 118668b4905a
 ---> 78bb87f20383
Removing intermediate container 118668b4905a
Step 3/8 : RUN sed -i ‘s/archive.ubuntu.com/mirrors.ustc.edu.cn/g‘ /etc/apt/sources.list
 ---> Running in 9bbb6c182746

 ---> 24ef42b63544
Removing intermediate container 9bbb6c182746
Step 4/8 : RUN apt-get update
 ---> Running in 2c8511a15eb7

Get:1 http://mirrors.ustc.edu.cn/ubuntu bionic InRelease [242 kB]
Get:2 http://mirrors.ustc.edu.cn/ubuntu bionic-updates InRelease [83.2 kB]
Get:3 http://mirrors.ustc.edu.cn/ubuntu bionic-backports InRelease [74.6 kB]
Get:4 http://mirrors.ustc.edu.cn/ubuntu bionic/universe Sources [11.5 MB]
Get:5 http://mirrors.ustc.edu.cn/ubuntu bionic/multiverse amd64 Packages [186 kB]
Get:6 http://mirrors.ustc.edu.cn/ubuntu bionic/restricted amd64 Packages [13.5 kB]
Get:7 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 Packages [1344 kB]
Get:8 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 Packages [11.3 MB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Get:10 http://mirrors.ustc.edu.cn/ubuntu bionic-updates/universe Sources [32.4 kB]
Get:11 http://mirrors.ustc.edu.cn/ubuntu bionic-updates/universe amd64 Packages [106 kB]
Get:12 http://mirrors.ustc.edu.cn/ubuntu bionic-updates/multiverse amd64 Packages [1663 B]
Get:13 http://mirrors.ustc.edu.cn/ubuntu bionic-updates/main amd64 Packages [178 kB]
Get:14 http://mirrors.ustc.edu.cn/ubuntu bionic-backports/universe amd64 Packages [2793 B]
Get:15 http://security.ubuntu.com/ubuntu bionic-security/universe Sources [5646 B]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [38.5 kB]
Get:17 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [123 kB]
Get:18 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [1075 B]
Fetched 25.4 MB in 8s (3044 kB/s)
Reading package lists...
 ---> b26a1de6e650
Removing intermediate container 2c8511a15eb7
Step 5/8 : RUN apt-get install -y nginx
 ---> Running in e88fccbe2bf6

Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  fontconfig-config fonts-dejavu-core geoip-database libbsd0 libexpat1
  libfontconfig1 libfreetype6 libgd3 libgeoip1 libicu60 libjbig0
  libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip
  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream libpng16-16 libssl1.1 libtiff5
  libwebp6 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxml2 libxpm4
  libxslt1.1 multiarch-support nginx-common nginx-core ucf
Suggested packages:
  libgd-tools geoip-bin fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
  fontconfig-config fonts-dejavu-core geoip-database libbsd0 libexpat1
  libfontconfig1 libfreetype6 libgd3 libgeoip1 libicu60 libjbig0
  libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip
  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream libpng16-16 libssl1.1 libtiff5
  libwebp6 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxml2 libxpm4
  libxslt1.1 multiarch-support nginx nginx-common nginx-core ucf
0 upgraded, 35 newly installed, 0 to remove and 7 not upgraded.
Need to get 16.1 MB of archives.
After this operation, 58.8 MB of additional disk space will be used.
Get:1 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 multiarch-support amd64 2.27-3ubuntu1 [6916 B]
Get:2 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libxau6 amd64 1:1.0.8-1 [8376 B]
Get:3 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libjpeg-turbo8 amd64 1.5.2-0ubuntu5 [110 kB]
Get:4 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libbsd0 amd64 0.8.7-1 [41.5 kB]
Get:5 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libexpat1 amd64 2.2.5-3 [80.2 kB]
Get:6 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libicu60 amd64 60.2-3ubuntu3 [8054 kB]
Get:7 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libssl1.1 amd64 1.1.0g-2ubuntu4 [1128 kB]
Get:8 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libxml2 amd64 2.9.4+dfsg1-6.1ubuntu1 [662 kB]
Get:9 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 ucf all 3.0038 [50.5 kB]
Get:10 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 geoip-database all 20180315-1 [2090 kB]
Get:11 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libgeoip1 amd64 1.6.12-1 [71.8 kB]
Get:12 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libpng16-16 amd64 1.6.34-1 [176 kB]
Get:13 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libxdmcp6 amd64 1:1.1.2-3 [10.7 kB]
Get:14 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libxcb1 amd64 1.13-1 [45.6 kB]
Get:15 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libx11-data all 2:1.6.4-3 [114 kB]
Get:16 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libx11-6 amd64 2:1.6.4-3 [572 kB]
Get:17 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 fonts-dejavu-core all 2.37-1 [1041 kB]
Get:18 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 fontconfig-config all 2.12.6-0ubuntu2 [55.8 kB]
Get:19 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libfreetype6 amd64 2.8.1-2ubuntu2 [335 kB]
Get:20 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libfontconfig1 amd64 2.12.6-0ubuntu2 [137 kB]
Get:21 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libjpeg8 amd64 8c-2ubuntu8 [2194 B]
Get:22 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libjbig0 amd64 2.1-3.1build1 [26.7 kB]
Get:23 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libtiff5 amd64 4.0.9-5 [152 kB]
Get:24 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libwebp6 amd64 0.6.1-2 [185 kB]
Get:25 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libxpm4 amd64 1:3.5.12-1 [34.0 kB]
Get:26 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libgd3 amd64 2.2.5-4 [118 kB]
Get:27 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 nginx-common all 1.14.0-0ubuntu1 [37.0 kB]
Get:28 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libnginx-mod-http-geoip amd64 1.14.0-0ubuntu1 [10.8 kB]
Get:29 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libnginx-mod-http-image-filter amd64 1.14.0-0ubuntu1 [14.2 kB]
Get:30 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libxslt1.1 amd64 1.1.29-5 [150 kB]
Get:31 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libnginx-mod-http-xslt-filter amd64 1.14.0-0ubuntu1 [12.6 kB]
Get:32 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libnginx-mod-mail amd64 1.14.0-0ubuntu1 [41.4 kB]
Get:33 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libnginx-mod-stream amd64 1.14.0-0ubuntu1 [63.3 kB]
Get:34 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 nginx-core amd64 1.14.0-0ubuntu1 [412 kB]
Get:35 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 nginx all 1.14.0-0ubuntu1 [3596 B]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 16.1 MB in 2s (7706 kB/s)
Selecting previously unselected package multiarch-support.
(Reading database ... 4035 files and directories currently installed.)
Preparing to unpack .../multiarch-support_2.27-3ubuntu1_amd64.deb ...
Unpacking multiarch-support (2.27-3ubuntu1) ...
Setting up multiarch-support (2.27-3ubuntu1) ...
Selecting previously unselected package libxau6:amd64.
(Reading database ... 4038 files and directories currently installed.)
Preparing to unpack .../00-libxau6_1%3a1.0.8-1_amd64.deb ...
Unpacking libxau6:amd64 (1:1.0.8-1) ...
Selecting previously unselected package libjpeg-turbo8:amd64.
Preparing to unpack .../01-libjpeg-turbo8_1.5.2-0ubuntu5_amd64.deb ...
Unpacking libjpeg-turbo8:amd64 (1.5.2-0ubuntu5) ...
Selecting previously unselected package libbsd0:amd64.
Preparing to unpack .../02-libbsd0_0.8.7-1_amd64.deb ...
Unpacking libbsd0:amd64 (0.8.7-1) ...
Selecting previously unselected package libexpat1:amd64.
Preparing to unpack .../03-libexpat1_2.2.5-3_amd64.deb ...
Unpacking libexpat1:amd64 (2.2.5-3) ...
Selecting previously unselected package libicu60:amd64.
Preparing to unpack .../04-libicu60_60.2-3ubuntu3_amd64.deb ...
Unpacking libicu60:amd64 (60.2-3ubuntu3) ...
Selecting previously unselected package libssl1.1:amd64.
Preparing to unpack .../05-libssl1.1_1.1.0g-2ubuntu4_amd64.deb ...
Unpacking libssl1.1:amd64 (1.1.0g-2ubuntu4) ...
Selecting previously unselected package libxml2:amd64.
Preparing to unpack .../06-libxml2_2.9.4+dfsg1-6.1ubuntu1_amd64.deb ...
Unpacking libxml2:amd64 (2.9.4+dfsg1-6.1ubuntu1) ...
Selecting previously unselected package ucf.
Preparing to unpack .../07-ucf_3.0038_all.deb ...
Moving old data out of the way
Unpacking ucf (3.0038) ...
Selecting previously unselected package geoip-database.
Preparing to unpack .../08-geoip-database_20180315-1_all.deb ...
Unpacking geoip-database (20180315-1) ...
Selecting previously unselected package libgeoip1:amd64.
Preparing to unpack .../09-libgeoip1_1.6.12-1_amd64.deb ...
Unpacking libgeoip1:amd64 (1.6.12-1) ...
Selecting previously unselected package libpng16-16:amd64.
Preparing to unpack .../10-libpng16-16_1.6.34-1_amd64.deb ...
Unpacking libpng16-16:amd64 (1.6.34-1) ...
Selecting previously unselected package libxdmcp6:amd64.
Preparing to unpack .../11-libxdmcp6_1%3a1.1.2-3_amd64.deb ...
Unpacking libxdmcp6:amd64 (1:1.1.2-3) ...
Selecting previously unselected package libxcb1:amd64.
Preparing to unpack .../12-libxcb1_1.13-1_amd64.deb ...
Unpacking libxcb1:amd64 (1.13-1) ...
Selecting previously unselected package libx11-data.
Preparing to unpack .../13-libx11-data_2%3a1.6.4-3_all.deb ...
Unpacking libx11-data (2:1.6.4-3) ...
Selecting previously unselected package libx11-6:amd64.
Preparing to unpack .../14-libx11-6_2%3a1.6.4-3_amd64.deb ...
Unpacking libx11-6:amd64 (2:1.6.4-3) ...
Selecting previously unselected package fonts-dejavu-core.
Preparing to unpack .../15-fonts-dejavu-core_2.37-1_all.deb ...
Unpacking fonts-dejavu-core (2.37-1) ...
Selecting previously unselected package fontconfig-config.
Preparing to unpack .../16-fontconfig-config_2.12.6-0ubuntu2_all.deb ...
Unpacking fontconfig-config (2.12.6-0ubuntu2) ...
Selecting previously unselected package libfreetype6:amd64.
Preparing to unpack .../17-libfreetype6_2.8.1-2ubuntu2_amd64.deb ...
Unpacking libfreetype6:amd64 (2.8.1-2ubuntu2) ...
Selecting previously unselected package libfontconfig1:amd64.
Preparing to unpack .../18-libfontconfig1_2.12.6-0ubuntu2_amd64.deb ...
Unpacking libfontconfig1:amd64 (2.12.6-0ubuntu2) ...
Selecting previously unselected package libjpeg8:amd64.
Preparing to unpack .../19-libjpeg8_8c-2ubuntu8_amd64.deb ...
Unpacking libjpeg8:amd64 (8c-2ubuntu8) ...
Selecting previously unselected package libjbig0:amd64.
Preparing to unpack .../20-libjbig0_2.1-3.1build1_amd64.deb ...
Unpacking libjbig0:amd64 (2.1-3.1build1) ...
Selecting previously unselected package libtiff5:amd64.
Preparing to unpack .../21-libtiff5_4.0.9-5_amd64.deb ...
Unpacking libtiff5:amd64 (4.0.9-5) ...
Selecting previously unselected package libwebp6:amd64.
Preparing to unpack .../22-libwebp6_0.6.1-2_amd64.deb ...
Unpacking libwebp6:amd64 (0.6.1-2) ...
Selecting previously unselected package libxpm4:amd64.
Preparing to unpack .../23-libxpm4_1%3a3.5.12-1_amd64.deb ...
Unpacking libxpm4:amd64 (1:3.5.12-1) ...
Selecting previously unselected package libgd3:amd64.
Preparing to unpack .../24-libgd3_2.2.5-4_amd64.deb ...
Unpacking libgd3:amd64 (2.2.5-4) ...
Selecting previously unselected package nginx-common.
Preparing to unpack .../25-nginx-common_1.14.0-0ubuntu1_all.deb ...
Unpacking nginx-common (1.14.0-0ubuntu1) ...
Selecting previously unselected package libnginx-mod-http-geoip.
Preparing to unpack .../26-libnginx-mod-http-geoip_1.14.0-0ubuntu1_amd64.deb ...
Unpacking libnginx-mod-http-geoip (1.14.0-0ubuntu1) ...
Selecting previously unselected package libnginx-mod-http-image-filter.
Preparing to unpack .../27-libnginx-mod-http-image-filter_1.14.0-0ubuntu1_amd64.deb ...
Unpacking libnginx-mod-http-image-filter (1.14.0-0ubuntu1) ...
Selecting previously unselected package libxslt1.1:amd64.
Preparing to unpack .../28-libxslt1.1_1.1.29-5_amd64.deb ...
Unpacking libxslt1.1:amd64 (1.1.29-5) ...
Selecting previously unselected package libnginx-mod-http-xslt-filter.
Preparing to unpack .../29-libnginx-mod-http-xslt-filter_1.14.0-0ubuntu1_amd64.deb ...
Unpacking libnginx-mod-http-xslt-filter (1.14.0-0ubuntu1) ...
Selecting previously unselected package libnginx-mod-mail.
Preparing to unpack .../30-libnginx-mod-mail_1.14.0-0ubuntu1_amd64.deb ...
Unpacking libnginx-mod-mail (1.14.0-0ubuntu1) ...
Selecting previously unselected package libnginx-mod-stream.
Preparing to unpack .../31-libnginx-mod-stream_1.14.0-0ubuntu1_amd64.deb ...
Unpacking libnginx-mod-stream (1.14.0-0ubuntu1) ...
Selecting previously unselected package nginx-core.
Preparing to unpack .../32-nginx-core_1.14.0-0ubuntu1_amd64.deb ...
Unpacking nginx-core (1.14.0-0ubuntu1) ...
Selecting previously unselected package nginx.
Preparing to unpack .../33-nginx_1.14.0-0ubuntu1_all.deb ...
Unpacking nginx (1.14.0-0ubuntu1) ...
Setting up libexpat1:amd64 (2.2.5-3) ...
Setting up libicu60:amd64 (60.2-3ubuntu3) ...
Setting up geoip-database (20180315-1) ...
Setting up libpng16-16:amd64 (1.6.34-1) ...
Setting up libjbig0:amd64 (2.1-3.1build1) ...
Setting up fonts-dejavu-core (2.37-1) ...
Setting up nginx-common (1.14.0-0ubuntu1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can‘t locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up libjpeg-turbo8:amd64 (1.5.2-0ubuntu5) ...
Setting up libgeoip1:amd64 (1.6.12-1) ...
Setting up libbsd0:amd64 (0.8.7-1) ...
Setting up ucf (3.0038) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can‘t locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up libxml2:amd64 (2.9.4+dfsg1-6.1ubuntu1) ...
Setting up libfreetype6:amd64 (2.8.1-2ubuntu2) ...
Setting up libxslt1.1:amd64 (1.1.29-5) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libssl1.1:amd64 (1.1.0g-2ubuntu4) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can‘t locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up libnginx-mod-mail (1.14.0-0ubuntu1) ...
Setting up libnginx-mod-http-xslt-filter (1.14.0-0ubuntu1) ...
Setting up libxdmcp6:amd64 (1:1.1.2-3) ...
Setting up libnginx-mod-http-geoip (1.14.0-0ubuntu1) ...
Setting up libx11-data (2:1.6.4-3) ...
Setting up libxau6:amd64 (1:1.0.8-1) ...
Setting up libwebp6:amd64 (0.6.1-2) ...
Setting up libjpeg8:amd64 (8c-2ubuntu8) ...
Setting up fontconfig-config (2.12.6-0ubuntu2) ...
Setting up libnginx-mod-stream (1.14.0-0ubuntu1) ...
Setting up libtiff5:amd64 (4.0.9-5) ...
Setting up libxcb1:amd64 (1.13-1) ...
Setting up libfontconfig1:amd64 (2.12.6-0ubuntu2) ...
Setting up libx11-6:amd64 (2:1.6.4-3) ...
Setting up libxpm4:amd64 (1:3.5.12-1) ...
Setting up libgd3:amd64 (2.2.5-4) ...
Setting up libnginx-mod-http-image-filter (1.14.0-0ubuntu1) ...
Setting up nginx-core (1.14.0-0ubuntu1) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up nginx (1.14.0-0ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
 ---> 0d85124c0053
Removing intermediate container e88fccbe2bf6
Step 6/8 : COPY index.html /var/www/html
 ---> 47982e76c320
Removing intermediate container 372e2185a512
Step 7/8 : ENTRYPOINT /usr/sbin/nginx g daemon off;
 ---> Running in a973e7d68e60
 ---> a7802784dfb1
Removing intermediate container a973e7d68e60
Step 8/8 : EXPOSE 8080
 ---> Running in b8455236eca0
 ---> 2230ac934a5f
Removing intermediate container b8455236eca0
Successfully built 2230ac934a5f

看到successfully就说明成功了

查看构建的镜像

[[email protected] dockerfile1]# docker images
REPOSITORY                                           TAG                 IMAGE ID            CREATED             SIZE
xbf/hello-nginx                                      latest              2230ac934a5f        16 minutes ago      179 MB
hello_docker                                         latest              65d690c9d782        57 minutes ago      4.15 MB
docker.io/ubuntu                                     latest              113a43faa138        11 days ago         81.2 MB
docker.io/centos                                     latest              49f7960eb7e4        12 days ago         200 MB
docker.io/stephenreed/jenkins-java8-maven-git        latest              3670d4afa617        2 months ago        682 MB
docker.io/alpine                                     latest              3fd9065eaf02        5 months ago        4.15 MB
docker.io/stephenreed/java8-jenkins-maven-git-nano   latest              508ef553bf1a        3 years ago         1.5 GB

运行构建好的镜像

[[email protected] dockerfile1]# docker run -d -p 8080:8080 xbf/hello-nginx
84d5d2b00de5544aa3810f9d1111f92dc4146c5bbafb6a02371a52b1a2b4575b

测试

[[email protected] dockerfile1]# curl http://localhost:8080

输出What day is it today?

原文地址:https://www.cnblogs.com/shamo89/p/9193260.html

时间: 2024-10-09 16:02:52

dockerfile+ubuntu+nginx搭建web环境的相关文章

Ubuntu上搭建Hadoop环境(单机模式+伪分布模式)【转】

[转自:]http://blog.csdn.net/hitwengqi/article/details/8008203 最近一直在自学Hadoop,今天花点时间搭建一个开发环境,并整理成文. 首先要了解一下Hadoop的运行模式: 单机模式(standalone)       单机模式是Hadoop的默认模式.当首次解压Hadoop的源码包时,Hadoop无法了解硬件安装环境,便保守地选择了最小配置.在这种默认模式下所有3个XML文件均为空.当配置文件为空时,Hadoop会完全运行在本地.因为不

Ubuntu上搭建Hadoop环境(单机模式+伪分布模式)

Hadoop在处理海量数据分析方面具有独天优势.今天花时间在自己的Linux上搭建了伪分布模式,期间经历很多曲折,现在将经验总结如下. 首先,了解Hadoop的三种安装模式: 1. 单机模式. 单机模式是Hadoop的默认模.当配置文件为空时,Hadoop完全运行在本地.因为不需要与其他节点交互,单机模式就不使用HDFS,也不加载任何Hadoop的守护进程.该模式主要用于开发调试MapReduce程序的应用逻辑. 2. 伪分布模式. Hadoop守护进程运行在本地机器上,模拟一个小规模的的集群.

Ubuntu Nginx搭建Gitweb服务器

安装Nginx 和 Gitweb [email protected]:~$ sudo apt-get install nginx gitweb 修改Gitweb配置文件 [email protected]:~/git-repo$ vim /etc/gitweb.conf 修改或添加以下: [plain] #Git库所处路径 $projectroot = "/home/simba/git-repo"; #启用追溯 $feature {'blame'}{'default'} = [1];

腾讯云搭建web环境基础指导

搭建web环境算是程序员的基础课了,但实际情况是一个刚出道的程序员都不会有自己的服务器,顶多花几十块钱买个域名,申请个免费虚拟主机,随便用ftp传个源码可以装逼无数了.真要花上几百大泮的月租只为小试身手肯定是划不来的,真要到了提枪上阵的时候绝对是两眼懵逼.有不少同学在自己电脑上装了虚拟环境,模拟服务器操作.当初我也是这么干的,确实能提高一些操作经验.但是,我不得不泼一些冷水,虚拟环境与真实环境还是有很多区别的,尤其是window的server环境,它不像linux,敲啥就出来啥.window s

ubuntu下搭建svn环境及其使用

ubuntu下搭建svn环境 软件下载安装: 我选用的是apt-get install subversion   操作系统自带的包管理工具安装,采用此法安装的软件方便管理,可以用dpkg -L subversion命令查看其所在安装目录. 注:ubuntu也有像archlinux相似的软件包搜索功能 , 搜索subversion 可以这么写apt-cache search subversion,就会列出所有匹配到的可选软件. 软件配置使用: 本环节其实就是在安装好subversion的操作系统中

快速搭建Web环境 Angularjs + Express3 + Bootstrap3

快速搭建Web环境 Angularjs + Express3 + Bootstrap3 AngularJS体验式编程系列文章, 将介绍如何用angularjs构建一个强大的web前端系统.angularjs是由Google团队开发的一款非常优秀web前端框架.在当前如此多 的web框架下,angularjs能脱颖而出,从架构设计上就高人一等,双向数据绑定,依赖注入,指令,MVC,模板.Angular.js创新地把后 台技术融入前端开发,扫去jQuery一度的光芒.用angularjs就像写后台代

ubuntu上搭建工作环境

版本ubuntu desktop, v12.4, v13.10. 优点: 1)绚丽易用的可视化环境: 2)丰富的可用package,在这点上比centos强太多,后者更新较慢: 不足: 1)在笔记本上运行较慢,笔记本很快温度变高:(特别是ThinkPad上) 2)是桌面端系统,所以作为一个用来进行程序开发的人来说需要装一些其他软件,但是方便易用的package安装方式减轻了这一过程的负担: a) 基本工具:cmake, svn, OpenSSH-server sudo apt-get insta

使用Haproxy及Nginx搭建Web群集

什么是HAProxy? HAProxy是一个使用C语言编写的自由及开放源代码软件,其提供高可用性.负载均衡,以及基于TCP和HTTP的应用程序代理,可以运行于大部分主流的Linux操作系统上.本次实验使用三台服务器搭建Web群集,Haproxy作为调度服务器,两台Nginx服务器作为节点服务器. 实验环境 主机 系统 IP地址 主要软件 Haproxy服务器 CentOS-7-x86_64 192.168.100.100 haproxy Nginx服务器1 CentOS-7-x86_64 192

CentOS7 上部署Haproxy及Nginx 搭建Web群集

HAProxy是一个使用C语言编写的自由及开放源代码软件,其提供高可用性.负载均衡,以及基于TCP和HTTP的应用程序代理,可以运行于大部分主流的Linux操作系统上.本次实验使用三台服务器搭建Web群集,Haproxy作为调度服务器,两台Nginx服务器作为节点服务器. 实验环境 主机 | 系统 | IP地址 | 只要软件 主机 系统 IP地址 主要软件 haproxy服务器 CentOS-7-x86_64 192.168.100.101 haproxy Nginx 服务器 CentOS-7-