爲何要使用容器?php
==================================================html
docker基礎java
爲何使用容器:node
==================================================mysql
docker基本使用(上)linux
docker基本使用:https://docs.docker.com/install/linux/docker-ce/centos/nginx
centos7.x安裝docker
c++
#安裝依賴包web
[root@k8s-node1 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2sql
#添加docker軟件包源
[root@k8s-node1 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
#安裝docker-ce
[root@k8s-node1 ~]# yum install docker-ce -y
# 啓動Docker服務並設置開機啓動
[root@k8s-node1 yum.repos.d]# systemctl start docker
[root@k8s-node1 yum.repos.d]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@k8s-node1 yum.repos.d]# docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.5
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1062.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.682GiB
Name: k8s-node1
ID: 4KMI:DWZZ:LGRD:B5YU:SWSA:RKJV:LYMA:4CV2:NED5:25NI:JVUT:O6ZB
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
#配置國內docker鏡像加速器:
https://www.daocloud.io/mirror#accelerator-doc
[root@k8s-node1 yum.repos.d]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
docker version >= 1.12
{"registry-mirrors": ["http://f1361db2.m.daocloud.io"]}
Success.
You need to restart docker to take effect: sudo systemctl restart docker
[root@k8s-node3 yum.repos.d]# docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.5
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1062.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.682GiB
Name: k8s-node3
ID: UDJF:ZHHF:SRAN:ZETK:KJCS:GDW3:K6RJ:XDKB:SHHG:3QZV:OMEE:PQ32
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
http://f1361db2.m.daocloud.io/
Live Restore Enabled: false
拉取鏡像:docker pull
[root@k8s-node1 ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
8ec398bc0356: Pulling fs layer
a53c868fbde7: Pulling fs layer
79daf9dd140d: Pulling fs layer
latest: Pulling from library/nginx
8ec398bc0356: Pull complete
a53c868fbde7: Pull complete
79daf9dd140d: Pull complete
Digest: sha256:28c9d0427097e5427cd313429b271c646c35b60fff05f543b15ed08fba3c09ff
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
鏡像的概念:
後臺啓動容器
[root@k8s-node1 ~]# docker run -d nginx
WARNING: IPv4 forwarding is disabled. Networking will not work.
57a9e55216687e6067b241eea4fc370d69ee206a77dde4e372ad9dbcd05d4034
查看運行的容器
[root@k8s-node1 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
57a9e5521668 nginx "nginx -g 'daemon of…" 28 seconds ago Up 26 seconds 80/tcp vibrant_ardinghelli
暴露容器端口,映射到對應主機的88端口
[root@k8s-node1 ~]# docker run -d -p 88:80 nginx
WARNING: IPv4 forwarding is disabled. Networking will not work.
b625b88ca907c772aa95653980710f29e58c2b223dbefcd10b0c5579a0ac84e9
進入容器:
[root@k8s-node3 ~]# docker exec -it 37d0dfe6597c bash
root@37d0dfe6597c:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
容器的隔離技術
1、namespace
1,UTS:主機和域名
2,IPC:好比消息隊列,共享內存
3,PID:進程編號
4,network:網絡協議棧的隔離,例如IP,端口
5,mount: 文件系統
6,User: 用戶和用戶組
2、cgroups: 資源限制,好比CPU、內存、磁盤IO
3、UFS:聯合文件系統,copy-on-write
VM1 鏡像模板 10G
VM2 10G
建立容器
一、應用暴露出去
二、主機名,IP
三、數據要不要持久化
四、變量傳入,作相關動做
[root@k8s-node1 ~]# docker run -d busybox ping baidu.com
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
bdbbaa22dec6: Pulling fs layer
latest: Pulling from library/busybox
bdbbaa22dec6: Pull complete
Digest: sha256:6915be4043561d64e0ab0f8f098dc2ac48e077fe23f488ac24b665166898115a
Status: Downloaded newer image for busybox:latest
d926cfa4a85d77b103d7b681f3bc1cfe2bd7abb66053845b1525b9f632b78d5a
[root@k8s-node1 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d926cfa4a85d busybox "ping baidu.com" 6 seconds ago Up 5 seconds pensive_merkle
[root@k8s-node1 ~]# docker exec -it d926cfa4a85d sh
/ # ps -l
PID USER TIME COMMAND
1 root 0:00 ping baidu.com
6 root 0:00 sh
11 root 0:00 ps -l
鏡像分層:
查看本地docker鏡像
[root@k8s-node1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 5ad3bd0e67a9 10 days ago 127MB
busybox latest 6d5fcfe5ff17 5 weeks ago 1.22MB
查看鏡像分層,每行就是一個鏡像層
[root@k8s-node1 ~]# docker history nginx
IMAGE CREATED CREATED BY SIZE COMMENT
5ad3bd0e67a9 10 days ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B
<missing> 10 days ago /bin/sh -c #(nop) STOPSIGNAL SIGTERM 0B
<missing> 10 days ago /bin/sh -c #(nop) EXPOSE 80 0B
<missing> 10 days ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx… 22B
<missing> 10 days ago /bin/sh -c set -x && addgroup --system -… 57.5MB
<missing> 10 days ago /bin/sh -c #(nop) ENV PKG_RELEASE=1~buster 0B
<missing> 10 days ago /bin/sh -c #(nop) ENV NJS_VERSION=0.3.8 0B
<missing> 10 days ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.17.8 0B
<missing> 5 weeks ago /bin/sh -c #(nop) LABEL maintainer=NGINX Do… 0B
<missing> 5 weeks ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 5 weeks ago /bin/sh -c #(nop) ADD file:04caaf303199c81ff… 69.2MB
==================================================
docker基本使用(下)
建立容器
一、應用暴露出去
二、主機名,IP
三、數據要不要持久化
四、變量傳入,作相關動做
五、資源限制,例如CPU,內存
資源限制:
[root@k8s-node1 ~]# cd wwwroot/
[root@k8s-node1 wwwroot]# ls
[root@k8s-node1 wwwroot]# touch index.html
[root@k8s-node1 wwwroot]# vim index.html
hello
[root@k8s-node3 ~]# docker run -d -p 8888:8080 --name web -e abc=123456 -v $PWD/wwwroot:/opt -m 1G --cpus="2" lizhenliang/java-demo
Unable to find image 'lizhenliang/java-demo:latest' locally
latest: Pulling from lizhenliang/java-demo
a02a4930cb5d: Pulling fs layer
12ac6c660ca4: Pulling fs layer
675ab56ce773: Pulling fs layer
10f8e813c167: Waiting
2347739fbd10: Waiting
latest: Pulling from lizhenliang/java-demo
a02a4930cb5d: Pull complete
12ac6c660ca4: Pull complete
675ab56ce773: Pull complete
10f8e813c167: Pull complete
2347739fbd10: Pull complete
Digest: sha256:4e43b2bcd81adf6d00b46a5c7efd384fc9f5b059c75255c8c89404ed4818bae3
Status: Downloaded newer image for lizhenliang/java-demo:latest
1a200c68bc46a5ffa732ac3b55d4216548746d25ef9e11e014f1d9539581eac6
[root@k8s-node1 ~]# lsof -i:8888
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 16121 root 4u IPv6 95649 0t0 TCP *:ddi-tcp-1 (LISTEN)
[root@k8s-node1 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8c57021d12da lizhenliang/java-demo "catalina.sh run" 9 minutes ago Up 9 minutes 0.0.0.0:8888->8080/tcp web
[root@k8s-node1 ~]# docker exec -it 8c57021d12da bash
[root@8c57021d12da tomcat]# ls
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE README.md RELEASE-NOTES RUNNING.txt bin conf lib logs temp webapps work
[root@8c57021d12da tomcat]# cd /opt/
[root@8c57021d12da opt]# ls
index.html
[root@8c57021d12da opt]# cat index.html
hello
-d 在後臺運行
-p 映射端口(將程序的8080端口映射爲宿主機的8888端口)
--name 容器名稱
-m 限制內存爲1G
--cpus 限制cpu數量爲2
-v 掛載本地的wwwroot目錄到容器下面的/opt目錄 -v bind mounts
-e 新加的參數
最後面接的是docker地址
訪問對應的IP地址和映射出去的端口,能夠獲得以下圖:
查看容器的狀態:
[root@k8s-node1 ~]# docker stats web
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
8c57021d12da web 0.21% 178.1MiB / 1GiB 17.40% 25.9kB / 750kB 0B / 0B 44
一、先在對應目錄建立文件
[root@k8s-node1 ~]# cd wwwroot/
[root@k8s-node1 wwwroot]# ls
index.html
[root@k8s-node1 wwwroot]# touch a.html
[root@k8s-node1 wwwroot]# ls
a.html index.html
二、中止容器
[root@k8s-node1 ~]# docker stop web
web
三、驗證是否中止成功
[root@k8s-node1 ~]# docker exec -it 8c57021d12da bash
Error response from daemon: Container 8c57021d12dab21ce66d5f90de498f2b17c4aab24e16022b7b8c00c99859ee1e is not running
[root@k8s-node1 ~]# ls
anaconda-ks.cfg wwwroot
[root@k8s-node1 ~]# cd wwwroot/
[root@k8s-node1 wwwroot]# ls
a.html index.html
[root@k8s-node1 wwwroot]# cd ..
[root@k8s-node1 ~]# ls
anaconda-ks.cfg wwwroot
四、從新啓動容器,進入對應目錄,看看是否還有那兩個文件,若是有,說明數據已經持久化了
[root@k8s-node1 ~]# docker start web
web
[root@k8s-node1 ~]# docker exec -it 8c57021d12da bash
[root@8c57021d12da tomcat]# ls
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE README.md RELEASE-NOTES RUNNING.txt bin conf lib logs temp webapps work
[root@8c57021d12da tomcat]# cd /opt/
[root@8c57021d12da opt]# ls
a.html index.html
掛載卷:
[root@k8s-node2 wwwroot]# docker volume ls
DRIVER VOLUME NAME
[root@k8s-node2 wwwroot]# cd
首先建立一個卷volume
[root@k8s-node2 ~]# docker volume create www
www
[root@k8s-node2 ~]# ls
anaconda-ks.cfg wwwroot
查看卷所對應的容器內目錄
[root@k8s-node2 ~]# docker volume inspect www
[
{
"CreatedAt": "2020-02-03T10:24:10+08:00",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/www/_data",
"Name": "www",
"Options": {},
"Scope": "local"
}
]
[root@k8s-node2 ~]# docker volume ls
DRIVER VOLUME NAME
local www
[root@k8s-node2 ~]# docker run -d -p 8888:8080 --name web -e abc=123456 -v $PWD/wwwroot:/opt -v www:/opt2 -m 1G --cpus="2" lizhenliang/java-demo
Unable to find image 'lizhenliang/java-demo:latest' locally
latest: Pulling from lizhenliang/java-demo
a02a4930cb5d: Pulling fs layer
12ac6c660ca4: Pulling fs layer
675ab56ce773: Pulling fs layer
10f8e813c167: Waiting
2347739fbd10: Waiting
latest: Pulling from lizhenliang/java-demo
a02a4930cb5d: Pull complete
12ac6c660ca4: Pull complete
675ab56ce773: Pull complete
10f8e813c167: Pull complete
2347739fbd10: Pull complete
Digest: sha256:4e43b2bcd81adf6d00b46a5c7efd384fc9f5b059c75255c8c89404ed4818bae3
Status: Downloaded newer image for lizhenliang/java-demo:latest
10ef7525e95aa9916b1c3f33a577c64ce95d3f15551cc2d44669a59169ecb3c0
[root@k8s-node2 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
10ef7525e95a lizhenliang/java-demo "catalina.sh run" 11 seconds ago Up 9 seconds 0.0.0.0:8888->8080/tcp web
[root@k8s-node2 ~]# docker exec -it 10ef7525e95a bash
[root@10ef7525e95a tomcat]# ls
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE README.md RELEASE-NOTES RUNNING.txt bin conf lib logs temp webapps work
[root@10ef7525e95a tomcat]# cd /opt2/
[root@10ef7525e95a opt2]# ls
[root@10ef7525e95a opt2]# touch {1..100}
[root@10ef7525e95a opt2]# ls
1 11 14 17 2 22 25 28 30 33 36 39 41 44 47 5 52 55 58 60 63 66 69 71 74 77 8 82 85 88 90 93 96 99
10 12 15 18 20 23 26 29 31 34 37 4 42 45 48 50 53 56 59 61 64 67 7 72 75 78 80 83 86 89 91 94 97
100 13 16 19 21 24 27 3 32 35 38 40 43 46 49 51 54 57 6 62 65 68 70 73 76 79 81 84 87 9 92 95 98
[root@10ef7525e95a opt2]# exit
exit
[root@k8s-node2 ~]# cd /var/lib/docker/volumes/www/_data
[root@k8s-node2 _data]# ls
1 11 14 17 2 22 25 28 30 33 36 39 41 44 47 5 52 55 58 60 63 66 69 71 74 77 8 82 85 88 90 93 96 99
10 12 15 18 20 23 26 29 31 34 37 4 42 45 48 50 53 56 59 61 64 67 7 72 75 78 80 83 86 89 91 94 97
100 13 16 19 21 24 27 3 32 35 38 40 43 46 49 51 54 57 6 62 65 68 70 73 76 79 81 84 87 9 92 95 98
[root@k8s-node2 _data]# cd -
/root
[root@k8s-node2 ~]# ls
anaconda-ks.cfg wwwroot
[root@k8s-node2 ~]# cd wwwroot/
[root@k8s-node2 wwwroot]# ls
index.html
[root@k8s-node2 ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
10ef7525e95a lizhenliang/java-demo "catalina.sh run" About a minute ago Up About a minute 0.0.0.0:8888->8080/tcp web
[root@k8s-node2 ~]# cd wwwroot/
[root@k8s-node2 wwwroot]# ls
index.html
[root@k8s-node2 wwwroot]# touch {a..z}
[root@k8s-node2 wwwroot]# ls
a b c d e f g h i index.html j k l m n o p q r s t u v w x y z
[root@k8s-node2 wwwroot]# ls
a b c d e f g h i index.html j k l m n o p q r s t u v w x y z
[root@k8s-node2 wwwroot]# docker exec -it 10ef7525e95a bash
[root@10ef7525e95a tomcat]# ls
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE README.md RELEASE-NOTES RUNNING.txt bin conf lib logs temp webapps work
[root@10ef7525e95a tomcat]# cd /opt
[root@10ef7525e95a opt]# ls
a b c d e f g h i index.html j k l m n o p q r s t u v w x y z
[root@10ef7525e95a opt]# exit
exit
[root@k8s-node2 wwwroot]#
由此可驗證,volume卷和目錄都已經掛載,並且在宿主機中建立文件,在容器中的對應目錄裏面仍然能夠看見文件。
==================================================
手把手教你製做鏡像(Dockerfile)
一、想讓公司項目容器化部署
什麼語言?
依賴環境?
服務端口?
中間件?
先啓動一個容器,在裏面跑通這個流程,而後拷貝到Dockerfile
nginx鏡像文件Dockerfile
[root@k8s-node3 nginx]# pwd
/root/nginx
[root@k8s-node3 nginx]# cat Dockerfile
FROM centos:7
LABEL maintainer chenjisong
RUN yum install epel-release -y
RUN yum install nginx -y
EXPOSE 80
WORKDIR /usr/local
CMD ["nginx", "-g", "daemon off;"]
[root@k8s-node3 nginx]# docker build -t nginx:yum -f Dockerfile .
...........................................................................
Removing intermediate container 7298f63a567a
---> a38ab190765d
Step 5/7 : EXPOSE 80
---> Running in f2f1af8ced1a
Removing intermediate container f2f1af8ced1a
---> 2e1086e92e81
Step 6/7 : WORKDIR /usr/local
---> Running in 43fd55f963e9
Removing intermediate container 43fd55f963e9
---> 0c205f779d5c
Step 7/7 : CMD ["nginx", "-g", "daemon off;"]
---> Running in fe7501f9c329
Removing intermediate container fe7501f9c329
---> 23670b1a7aab
Successfully built 23670b1a7aab
Successfully tagged nginx:yum
[root@k8s-node3 nginx]# docker run -d -p 8887:80 23670b1a7aab
1167e64be7a689bb885c0495e4df985faecae900538b33f0a763d4ec79005384
[root@k8s-node3 tomcat]# ls
apache-tomcat-8.5.43.tar.gz Dockerfile
[root@k8s-node3 tomcat]# cat Dockerfile
FROM centos:7
MAINTAINER www.51cto.com
ENV VERSION=8.5.43
RUN yum install java-1.8.0-openjdk wget curl unzip iproute net-tools -y && \
yum clean all && \
rm -rf /var/cache/yum/*
COPY apache-tomcat-${VERSION}.tar.gz /
RUN tar -zxvf apache-tomcat-${VERSION}.tar.gz && \
mv apache-tomcat-${VERSION} /usr/local/tomcat && \
rm -rf apache-tomcat-${VERSION}.tar.gz /usr/local/tomcat/webapps/* && \
mkdir /usr/local/tomcat/webapps/test && \
echo "ok" > /usr/local/tomcat/webapps/test/status.html && \
sed -i '1a JAVA_OPTS="-Djava.security.edg=file:/dev/ ./urandom"' /usr/local/tomcat/bin/catalina.sh && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ENV PATH $PATH:/usr/local/tomcat/bin
WORKDIR /usr/local/tomcat
EXPOSE 8080
CMD ["catalina.sh", "run"]
[root@k8s-node3 tomcat]# docker build -t nginx:complication -f Dockerfile .
[root@k8s-node3 php]# ls
Dockerfile php-5.6.36.tar.gz php-fpm.conf php.ini
[root@k8s-node3 php]# cat Dockerfile
FROM centos:7
MAINTAINER www.ctnrs.com
RUN yum install epel-release -y && \
yum install -y gcc gcc-c++ make gd-devel libxml2-devel \
libcurl-devel libjpeg-devel libpng-devel openssl-devel \
libmcrypt-devel libxslt-devel libtidy-devel autoconf \
iproute net-tools telnet wget curl && \
yum clean all && \
rm -rf /var/cache/yum/*
COPY php-5.6.36.tar.gz /
RUN tar -zxvf php-5.6.36.tar.gz && \
cd php-5.6.36 && \
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm --enable-opcache \
--with-mysql --with-mysqli --with-pdo-mysql \
--with-openssl --with-zlib --with-curl --with-gd \
--with-jpeg-dir --with-png-dir --with-freetype-dir \
--enable-mbstring --with-mcrypt --enable-hash && \
make -j 4 && make install && \
cp php.ini-production /usr/local/php/etc/php.ini && \
cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf && \
sed -i "90a \daemonize = no" /usr/local/php/etc/php-fpm.conf && \
mkdir /usr/local/php/log && \
cd / && rm -rf php* && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ENV PATH $PATH:/usr/local/php/sbin
COPY php.ini /usr/local/php/etc
COPY php-fpm.conf /usr/local/php/etc
WORKDIR /usr/local/php
EXPOSE 9000
CMD ["php-fpm"]
[root@k8s-node3 php]# docker build -t php:complication -f Dockerfile .
[root@k8s-node3 nginx]# ls
Dockerfile nginx-1.15.5.tar.gz nginx.conf
[root@k8s-node3 nginx]# cat Dockerfile
FROM centos:7
LABEL maintainer www.ctnrs.com
RUN yum install -y gcc gcc-c++ make \
openssl-devel pcre-devel gd-devel \
iproute net-tools telnet wget curl && \
yum clean all && \
rm -rf /var/cache/yum/*
COPY nginx-1.15.5.tar.gz /
RUN tar zxvf nginx-1.15.5.tar.gz && \
cd nginx-1.15.5 && \
./configure --prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_stub_status_module && \
make -j 4 && make install && \
rm -rf /usr/local/nginx/html/* && \
echo "ok" >> /usr/local/nginx/html/status.html && \
cd / && rm -rf nginx* && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ENV PATH $PATH:/usr/local/nginx/sbin
COPY nginx.conf /usr/local/nginx/conf/nginx.conf
WORKDIR /usr/local/nginx
EXPOSE 80
CMD ["nginx","-g","daemon off;"]
[root@k8s-node3 nginx]# docker build -t nginx:complication -f Dockerfile .
[root@k8s-node3 web]# cd java/
[root@k8s-node3 java]# ls
Dockerfile
[root@k8s-node3 java]# cat Dockerfile
FROM java:8-jdk-alpine
LABEL maintainer www.ctnrs.com
ENV JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF8 -Duser.timezone=GMT+08"
RUN apk add -U tzdata && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
COPY ./target/eureka-service.jar ./
EXPOSE 8888
CMD java -jar $JAVA_OPTS /eureka-service.jar