部署project_exam_system项目——及容器的编排

2024-09-01 12:12

本文主要是介绍部署project_exam_system项目——及容器的编排,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

(一)安装docker、编辑daemon.json文件、安装docker-compose编排容器、启动docker

1.环境准备

[root@docker--1 ~]# rz -Erz waiting to receive.[root@docker--1 ~]# lsanaconda-ks.cfg  docker.sh[root@docker--1 ~]# source docker.sh [root@docker--1 ~]# vim /etc/docker/daemon.json [root@docker--1 ~]# vim /usr/lib/systemd/system/docker.service[root@docker--1 ~]# systemctl daemon-reload[root@docker--1 ~]# systemctl start docker

脚本内容如下:

cat << EOF | tee /etc/modules-load.d/k8s.conf 
overlay
br_netfilter
EOFmodprobe overlaymodprobe br_netfiltercat << EOF | tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOFsysctl --systemyum install -y yum-utils device-mapper-persistent-data lvm2yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoyum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

2.普通部署

按照正常步骤安装docker,这里可参考前面的笔记

3.拉取nginx镜像

[root@docker3 ~]# docker pull nginxUsing default tag: latestlatest: Pulling from library/nginxDigest: sha256:447a8665cc1dab95b1ca778e162215839ccbb9189104c79d7ec3a81e14577addStatus: Image is up to date for nginx:latestdocker.io/library/nginx:latest

4.查看镜像

[root@docker3 ~]# docker imagesREPOSITORY   TAG       IMAGE ID       CREATED       SIZEnginx        latest    5ef79149e0ec   2 weeks ago   188MB

5.创建nginx容器

[root@docker--1 ~]# docker run -itd -p80:80 nginx:latest a9200f608c60aa1c8827b5562b7906d543d48e38c06f76bdb1b702ce73209117

6.查看容器

[root@docker--1 ~]# docker psCONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS             NAMESa9200f608c60   nginx:latest   "/docker-entrypoint.…"   19 seconds ago   Up 17 seconds cp   stupefied_feistel

进行验证

[root@docker--1 ~]# curl localhost<!DOCTYPE html><html><head><title>Welcome to nginx!</title><style>html { color-scheme: light dark; }body { width: 35em; margin: 0 auto;font-family: Tahoma, Verdana, Arial, sans-serif; }</style></head><body><h1>Welcome to nginx!</h1><p>If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.</p><p>For online documentation and support please refer tonginx.org.<br/>Commercial support is available atnginx.com.</p><p><em>Thank you for using nginx.</em></p></body></html>

注:容器启动后nginx服务就自动发布了,浏览器也能够看到nginx页面

(二)部署project_exam_system项目

创建一个目录,放置前端和后端的资料

[root@docker--1 ~]# mkdir project_exam_system

切入到所创建的目录中

[root@docker--1 ~]# cd project_exam_system/

创建web目录

[root@docker--1 project_exam_system]# mkdir web

切入到web目录下

[root@docker--1 project_exam_system]# cd web/

拖拽dist.zip的压缩包

[root@docker--1 web]# rz -Erz waiting to receive.[root@docker--1 web]# lsdist.zip

安装unzip

[root@docker--1 web]# yum -y install unzip

使用unzip进行解压dist.zip的包

[root@docker--1 web]# unzip dist.zip [root@docker--1 web]# lsdist  dist.zip[root@docker--1 web]# cd ..

停止并删除前面所创建的容器

停止容器

[root@docker--1 project_exam_system]# docker stop a92

a92

删除容器

[root@docker--1 project_exam_system]# docker rm a92

a92

创建容器,进行映射端口和挂载目录

[root@docker--1 project_exam_system]# docker run -itd -p80:80 -v /root/project_exam_syml/ nginx:latest 7c7f8bbb4ae732042b9ad3060d58f5c595f76fd7348b2b8e5beea857f74cf6e2

浏览器访问

采用域名劫持设置域名

顾名思义也就是修改物理机上的hosts文件来达到效果

修改hosts文件

后端业务jdk17、springboot

 #拉取centos镜像[root@docker--1 project_exam_system]# docker pull centos#回到根目录[root@docker--1 project_exam_system]# cd#拖拽项目资源和jdk17版本的文件#项目资源:application.propertiesProject_ExamSystem-V1.0.0.war#jdk17版本的文件:  jdk-17_linux-x64_bin.tar.gz  [root@docker--1 ~]# rz -E
rz waiting to receive.
[root@docker--1 ~]# rz -E
rz waiting to receive.
[root@docker--1 ~]# rz -E
rz waiting to receive.#查看 [root@docker--1 ~]# ls
anaconda-ks.cfg         docker.sh                    project_exam_system
application.properties  jdk-17_linux-x64_bin.tar.gz  Project_ExamSystem-V1.0.0.war#使用centos镜像创建容器[root@docker--1 ~]# docker run -it centos:latest /bin/bash#使用ctrl p+q退出[root@2267541087e9 /]# [root@docker--1 ~]# #查看容器[root@docker--1 ~]# docker ps
CONTAINER ID   IMAGE           COMMAND                   CREATED          STATUS          PORTS                               NAMES
2267541087e9   centos:latest   "/bin/bash"               44 seconds ago   Up 43 seconds                                       hardcore_raman
7c7f8bbb4ae7   nginx:latest    "/docker-entrypoint.…"   34 minutes ago   Up 34 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp   thirsty_babbage#将在服务器上的java文件上传到容器[root@docker--1 ~]# docker cp jdk-17_linux-x64_bin.tar.gz 226:/
Successfully copied 183MB to 226:/
[root@docker--1 ~]# docker cp application.properties 226:/
Successfully copied 4.1kB to 226:/
[root@docker--1 ~]# docker cp Project_ExamSystem-V1.0.0.war 226:/
Successfully copied 41MB to 226:/#对已经传到容器的文件进行部署[root@docker--1 ~]# docker attach 226[root@2267541087e9 /]# ls    
Project_ExamSystem-V1.0.0.war  home			    media  run	 usr
application.properties	       jdk-17_linux-x64_bin.tar.gz  mnt    sbin  var
bin			       lib			    opt    srv
dev			       lib64			    proc   sys
etc			       lost+found		    root   tmp#创建目录[root@2267541087e9 /]# mkdir /usr/local/jdk[root@2267541087e9 /]# tar -zxvf jdk-17_linux-x64_bin.tar.gz -C /usr/local/jdk/ --strip-components=1[root@2267541087e9 /]# vi application.properties spring.datasource.url=jdbc:mysql://192.168.1.24:3306/project exam system
spring.datasource.username=dd
spring.datasource.password=1
spring,datasource.driver-class-name=com.mysal.cj.jdbc.Driver[root@2267541087e9 /]# /usr/local/jdk/bin/java -jar Project_ExamSystem-V1.0.0.war .   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::                (v3.3.2)running for 8.671)
read escape sequence
[root@docker--1 ~]# curl 172.17.0.3:8080
{"code":20002,"msg":"账号不存在或密码错误"}[root@docker--1 ~]# 
[root@docker--1 ~]# docker commit 226 java:v0
sha256:cf1a38ea2001eac37d139eaa9d76899aed7e3521fcd7c07588edcf705f817add
[root@docker--1 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
java         v0        cf1a38ea2001   8 seconds ago   774MB
nginx        latest    5ef79149e0ec   2 weeks ago     188MB
centos       latest    5d0da3dc9764   2 years ago     231MB
[root@docker--1 ~]# docker ps
CONTAINER ID   IMAGE           COMMAND                   CREATED             STATUS             PORTS                               NAMES
2267541087e9   centos:latest   "/bin/bash"               38 minutes ago      Up 38 minutes                                          hardcore_raman
7c7f8bbb4ae7   nginx:latest    "/docker-entrypoint.…"   About an hour ago   Up About an hour   0.0.0.0:80->80/tcp, :::80->80/tcp   thirsty_babbage
[root@docker--1 ~]# docker stop 226
226
[root@docker--1 ~]# docker rm 226
[root@docker--1 ~]# docker run -itd -p8080:8080 java:v0 
d3a039010bf133b0dffa280664274d517f2c149d751ab45883d3dfc08dc2f5cc
[root@docker--1 ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED             STATUS             PORTS                                       NAMES
d3a039010bf1   java:v0        "/bin/bash"               12 seconds ago      Up 11 seconds      0.0.0.0:8080->8080/tcp, :::8080->8080/tcp   quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   About an hour ago   Up About an hour   0.0.0.0:80->80/tcp, :::80->80/tcp           thirsty_babbage
[root@docker--1 ~]# docker attach d3a
[root@d3a039010bf1 /]# /usr/local/jdk/bin/java -jar Project_ExamSystem-V1.0.0.war .   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::                (v3.3.2)running for 8.057)
read escape sequence
ctrl p+q退出
[root@docker--1 ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED             STATUS             PORTS                                       NAMES
d3a039010bf1   java:v0        "/bin/bash"               11 minutes ago      Up 11 minutes      0.0.0.0:8080->8080/tcp, :::8080->8080/tcp   quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   About an hour ago   Up About an hour   0.0.0.0:80->80/tcp, :::80->80/tcp           thirsty_babbage

 浏览器访问

#拉取mysql镜像
[root@docker--1 ~]# docker pull mysql:5.7.44
#创建容器,指定端口映射
[root@docker--1 ~]# docker run -itd -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 mysql:5.7.44
48fd8551ec838b218bd853bb49e99fb4650ebd3c22a93d214a2cc64941eae141
#查看容器
[root@docker--1 ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS          PORTS                                                  NAMES
48fd8551ec83   mysql:5.7.44   "docker-entrypoint.s…"   15 seconds ago   Up 14 seconds   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   flamboyant_nash
d3a039010bf1   java:v0        "/bin/bash"               3 hours ago      Up 3 hours      0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   5 hours ago      Up 5 hours      0.0.0.0:80->80/tcp, :::80->80/tcp                      thirsty_babbage
#切入到project_exam_system目录下
[root@docker--1 ~]# cd project_exam_system/
[root@docker--1 project_exam_system]# ls
project_exam_system.sql  web
#创建mysql目录
[root@docker--1 project_exam_system]# mkdir mysql
#移动文件
#将project_exam_system.sql移动到mysql目录下
[root@docker--1 project_exam_system]# mv project_exam_system.sql mysql/
#将project_exam_system.sql复制到容器[root@docker--1 ~]# docker cp project_exam_system/mysql/project_exam_system.sql 48fd:/
Successfully copied 11MB to 48fd:/
#查看镜像[root@docker--1 ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
java         v0        cf1a38ea2001   4 hours ago    774MB
nginx        latest    5ef79149e0ec   2 weeks ago    188MB
mysql        5.7.44    5107333e08a8   8 months ago   501MB
centos       latest    5d0da3dc9764   2 years ago    231MB
[root@docker--1 ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS          PORTS                                                  NAMES
48fd8551ec83   mysql:5.7.44   "docker-entrypoint.s…"   13 minutes ago   Up 13 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   flamboyant_nash
d3a039010bf1   java:v0        "/bin/bash"               3 hours ago      Up 3 hours      0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   5 hours ago      Up 5 hours      0.0.0.0:80->80/tcp, :::80->80/tcp                      thirsty_babbage
[root@docker--1 ~]# docker exec -it 48fd mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.44 MySQL Community Server (GPL)Copyright (c) 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;
+---------------------+
| Database            |
+---------------------+
| information_schema  |
| mysql               |
| performance_schema  |
| project_exam_system |
| sys                 |
+---------------------+
5 rows in set (0.00 sec)mysql> use project_exam_system;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
mysql> select * from user;
+-----+--------------+----------+--------+---------------------+----------+---------------------+--------+-------+
| id  | userName     | password | status | createTime          | createOr | editTime            | editOr | isDel |
+-----+--------------+----------+--------+---------------------+----------+---------------------+--------+-------+
|   1 | 21001189     | 111111   |      0 | 2024-08-21 09:45:05 | NULL     | 2024-08-22 22:04:44 | NULL   |     0 |
|   2 | 21001190     | 111111   |      0 | 2024-08-21 09:45:05 | NULL     | 2024-08-21 09:45:05 | NULL   |     0 |
|   3 | 21001191     | 111111   |      0 | 2024-08-21 09:45:05 | NULL     | 2024-08-21 09:45:05 | NULL   |     0 |
|   4 | 21001192     | 111111   |      0 | 2024-08-21 09:45:05 | NULL     | 2024-08-21 09:45:05 | NULL   |     0 |
|   5 | 21001193     | 111111   |      0 | 2024-08-21 09:45:05 | NULL     | 2024-08-21 09:45:05 | NULL   |     0 |
|   6 | 21001194     | 111111   |      0 | 2024-08-21 09:45:05 | NULL     | 2024-08-21 09:45:05 | NULL   |     0 |mysql> create user 'dd'@'%' identified by '1';
Query OK, 0 rows affected (0.01 sec)mysql> grant all on *.* to 'dd'@'%';
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> exit
Bye
[root@docker--1 ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS          PORTS                                                  NAMES
48fd8551ec83   mysql:5.7.44   "docker-entrypoint.s…"   27 minutes ago   Up 27 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   flamboyant_nash
d3a039010bf1   java:v0        "/bin/bash"               4 hours ago      Up 4 hours      0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   5 hours ago      Up 5 hours      0.0.0.0:80->80/tcp, :::80->80/tcp                      thirsty_babbage
[root@docker--1 ~]# ls
anaconda-ks.cfg         jdk-17_linux-x64_bin.tar.gz  Project_ExamSystem-V1.0.0.war
application.properties  mysql
docker.sh               project_exam_system
[root@docker--1 ~]# mkdir project_exam_system/java
[root@docker--1 ~]# mv jdk-17_linux-x64_bin.tar.gz project_exam_system/java/
[root@docker--1 ~]# mv application.properties project_exam_system/java/
[root@docker--1 ~]# mv Project_ExamSystem-V1.0.0.war project_exam_system/java/
[root@docker--1 ~]# ls
anaconda-ks.cfg  docker.sh  mysql  project_exam_system
[root@docker--1 ~]# tree -L 3 project_exam_system/
project_exam_system/
├── java
│   ├── application.properties
│   ├── jdk-17_linux-x64_bin.tar.gz
│   └── Project_ExamSystem-V1.0.0.war
├── mysql
│   └── project_exam_system.sql
└── web├── dist│   ├── assets│   ├── favicon.ico│   └── index.html└── dist.zip5 directories, 7 files[root@docker--1 ~]# cd project_exam_system/java/
[root@docker--1 java]# rz -E
rz waiting to receive.
[root@docker--1 java]# ls
application.properties  jdk-17_linux-x64_bin.tar.gz
Dockerfile              Project_ExamSystem-V1.0.0.war
[root@docker--1 java]# docker build -t java:v1 .
[root@docker--1 java]# ls
application.properties  jdk-17_linux-x64_bin.tar.gz
Dockerfile              Project_ExamSystem-V1.0.0.war
[root@docker--1 java]# tar -zxvf jdk-17_linux-x64_bin.tar.gz [root@docker--1 java]# ls
application.properties  jdk-17.0.12                  Project_ExamSystem-V1.0.0.war
Dockerfile              jdk-17_linux-x64_bin.tar.gz
[root@docker--1 java]# mv jdk-17.0.12/ jdk
[root@docker--1 java]# ls
application.properties  jdk                          Project_ExamSystem-V1.0.0.war
Dockerfile              jdk-17_linux-x64_bin.tar.gz
[root@docker--1 java]# vim Dockerfile 
[root@docker--1 java]# docker build -t java:v1 .
[+] Building 5.5s (9/10)                                              docker:default=> [internal] load build definition from Dockerfile                            0.0s=> => transferring dockerfile: 405B                                            0.0s=> [internal] load metadata for docker.io/library/centos:latest                0.0s=> [internal] load .dockerignore                                               0.0s=> => transferring context: 2B                                                 0.0s=> [1/7] FROM docker.io/library/centos:latest                                  0.0s=> [internal] load build context                                               3.6s=> => transferring context: 318.73MB                                           3.6s=> CACHED [2/7] ADD application.properties /application.properties             0.0s=> [3/7] ADD jdk/ /usr/local/jdk/                                              1.2s=> [4/7] ADD Project_ExamSystem-V1.0.0.war /Project_ExamSystem-V1.0.0.war      0.2s=> ERROR [5/7] RUN mkdir /usr/local/jdk                                        0.4s
------                                                                               > [5/7] RUN mkdir /usr/local/jdk:
0.361 mkdir: cannot create directory '/usr/local/jdk': File exists
------
Dockerfile:13
--------------------11 |     EXPOSE 808012 |     13 | >>> RUN mkdir /usr/local/jdk14 |     15 |     RUN tar -zxvf /jdk-17_linux-x64_bin.tar.gz -C /usr/local/jdk --strip-components=1
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir /usr/local/jdk" did not complete successfully: exit code: 1
[root@docker--1 java]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
java         v0        cf1a38ea2001   5 hours ago    774MB
nginx        latest    5ef79149e0ec   2 weeks ago    188MB
mysql        5.7.44    5107333e08a8   8 months ago   501MB
centos       latest    5d0da3dc9764   2 years ago    231MB
[root@docker--1 java]# vim Dockerfile 
[root@docker--1 java]# docker build -t java:v1 .
[+] Building 2.4s (10/10) FINISHED                                    docker:default=> [internal] load build definition from Dockerfile                            0.0s=> => transferring dockerfile: 404B                                            0.0s=> [internal] load metadata for docker.io/library/centos:latest                0.0s=> [internal] load .dockerignore                                               0.0s=> => transferring context: 2B                                                 0.0s=> [1/7] FROM docker.io/library/centos:latest                                  0.0s=> [internal] load build context                                               0.0s=> => transferring context: 25.82kB                                            0.0s=> CACHED [2/7] ADD application.properties /application.properties             0.0s=> [3/7] ADD jdk/ /usr/loca/jdk/                                               1.2s=> [4/7] ADD Project_ExamSystem-V1.0.0.war /Project_ExamSystem-V1.0.0.war      0.2s=> [5/7] RUN mkdir /usr/local/jdk                                              0.4s=> ERROR [6/7] RUN tar -zxvf /jdk-17_linux-x64_bin.tar.gz -C /usr/local/jdk -  0.4s
------                                                                               > [6/7] RUN tar -zxvf /jdk-17_linux-x64_bin.tar.gz -C /usr/local/jdk --strip-components=1:                                                                               
0.306 tar (child): /jdk-17_linux-x64_bin.tar.gz: Cannot open: No such file or directory
0.306 tar (child): Error is not recoverable: exiting now
0.308 tar: Child returned status 2
0.308 tar: Error is not recoverable: exiting now
------
Dockerfile:15
--------------------13 |     RUN mkdir /usr/local/jdk14 |     15 | >>> RUN tar -zxvf /jdk-17_linux-x64_bin.tar.gz -C /usr/local/jdk --strip-components=116 |     17 |     CMD [ "/usr/local/jdk/bin/java -jar Project_ExamSystem-V1.0.0.war" ]
--------------------
ERROR: failed to solve: process "/bin/sh -c tar -zxvf /jdk-17_linux-x64_bin.tar.gz -C /usr/local/jdk --strip-components=1" did not complete successfully: exit code: 2
[root@docker--1 java]# vim Dockerfile 
[root@docker--1 java]# docker build -t java:v1 .
[+] Building 0.4s (9/9) FINISHED                                      docker:default=> [internal] load build definition from Dockerfile                            0.0s=> => transferring dockerfile: 321B                                            0.0s=> [internal] load metadata for docker.io/library/centos:latest                0.0s=> [internal] load .dockerignore                                               0.0s=> => transferring context: 2B                                                 0.0s=> [1/6] FROM docker.io/library/centos:latest                                  0.0s=> [internal] load build context                                               0.0s=> => transferring context: 25.82kB                                            0.0s=> CACHED [2/6] ADD application.properties /application.properties             0.0s=> CACHED [3/6] ADD jdk /usr/local/jdk/                                        0.0s=> CACHED [4/6] ADD Project_ExamSystem-V1.0.0.war /Project_ExamSystem-V1.0.0.  0.0s=> ERROR [5/6] RUN mkdir /usr/local/jdk                                        0.3s
------                                                                               > [5/6] RUN mkdir /usr/local/jdk:
0.246 mkdir: cannot create directory '/usr/local/jdk': File exists
------
Dockerfile:13
--------------------11 |     EXPOSE 808012 |     13 | >>> RUN mkdir /usr/local/jdk14 |     15 |     CMD [ "/usr/local/jdk/bin/java -jar Project_ExamSystem-V1.0.0.war" ]
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir /usr/local/jdk" did not complete successfully: exit code: 1
[root@docker--1 java]# vim Dockerfile 
[root@docker--1 java]# docker build -t java:v1 .
[+] Building 2.2s (9/9) FINISHED                                      docker:default=> [internal] load build definition from Dockerfile                            0.0s=> => transferring dockerfile: 295B                                            0.0s=> [internal] load metadata for docker.io/library/centos:latest                0.0s=> [internal] load .dockerignore                                               0.0s=> => transferring context: 2B                                                 0.0s=> [1/5] FROM docker.io/library/centos:latest                                  0.0s=> [internal] load build context                                               0.0s=> => transferring context: 25.82kB                                            0.0s=> CACHED [2/5] ADD application.properties /application.properties             0.0s=> CACHED [3/5] ADD jdk /usr/local/jdk/                                        0.0s=> CACHED [4/5] ADD Project_ExamSystem-V1.0.0.war /Project_ExamSystem-V1.0.0.  0.0s=> exporting to image                                                          2.0s=> => exporting layers                                                         2.0s=> => writing image sha256:8738b8a36bf97b7066911888fcc6ccfde793b4f42892be3fe7  0.0s=> => naming to docker.io/library/java:v1                                      0.0s
[root@docker--1 java]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
java         v1        8738b8a36bf9   5 minutes ago   591MB
java         v0        cf1a38ea2001   5 hours ago     774MB
nginx        latest    5ef79149e0ec   2 weeks ago     188MB
mysql        5.7.44    5107333e08a8   8 months ago    501MB
centos       latest    5d0da3dc9764   2 years ago     231MB
[root@docker--1 java]# docker run -itd -p8080:8080 java:v1 /bin/bash
0379c12f93fc7d06c6a236fe53d3db73b8a74387eb6dac439cf3de7a0fee9073
docker: Error response from daemon: driver failed programming external connectivity on endpoint dreamy_jones (f34b58f6da48030ef97dad4802d6d0e9191c078f6f047b8b96999b0549fc8b16): Bind for 0.0.0.0:8080 failed: port is already allocated.
[root@docker--1 java]# docker run -itd -p8081:8080 java:v1 /bin/bash
a3c4fbc92430316aae70755992d76c3d1d2868560f61e1cbbfb5dc57eb93cd4b
[root@docker--1 java]# docker ps --all
CONTAINER ID   IMAGE          COMMAND                   CREATED              STATUS             PORTS                                                  NAMES
a3c4fbc92430   java:v1        "/bin/bash"               55 seconds ago       Up 55 seconds      0.0.0.0:8081->8080/tcp, :::8081->8080/tcp              heuristic_carson
0379c12f93fc   java:v1        "/bin/bash"               About a minute ago   Created                                                                   dreamy_jones
48fd8551ec83   mysql:5.7.44   "docker-entrypoint.s…"   About an hour ago    Up About an hour   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   flamboyant_nash
d3a039010bf1   java:v0        "/bin/bash"               5 hours ago          Up 5 hours         0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   6 hours ago          Up 6 hours         0.0.0.0:80->80/tcp, :::80->80/tcp                      thirsty_babbage
[root@docker--1 java]# docker stop 037
037
[root@docker--1 java]# docker rm 037
037
[root@docker--1 java]# docker ps --all
CONTAINER ID   IMAGE          COMMAND                   CREATED              STATUS              PORTS                                                  NAMES
a3c4fbc92430   java:v1        "/bin/bash"               About a minute ago   Up About a minute   0.0.0.0:8081->8080/tcp, :::8081->8080/tcp              heuristic_carson
48fd8551ec83   mysql:5.7.44   "docker-entrypoint.s…"   2 hours ago          Up 2 hours          0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   flamboyant_nash
d3a039010bf1   java:v0        "/bin/bash"               5 hours ago          Up 5 hours          0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   6 hours ago          Up 6 hours          0.0.0.0:80->80/tcp, :::80->80/tcp                      thirsty_babbage
[root@docker--1 java]# docker rm  heuristic_carson
Error response from daemon: cannot remove container "/heuristic_carson": container is running: stop the container before removing or force remove
[root@docker--1 java]# docker ps --all
CONTAINER ID   IMAGE          COMMAND                   CREATED         STATUS         PORTS                                                  NAMES
a3c4fbc92430   java:v1        "/bin/bash"               2 minutes ago   Up 2 minutes   0.0.0.0:8081->8080/tcp, :::8081->8080/tcp              heuristic_carson
48fd8551ec83   mysql:5.7.44   "docker-entrypoint.s…"   2 hours ago     Up 2 hours     0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   flamboyant_nash
d3a039010bf1   java:v0        "/bin/bash"               5 hours ago     Up 5 hours     0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   6 hours ago     Up 6 hours     0.0.0.0:80->80/tcp, :::80->80/tcp                      thirsty_babbage
[root@docker--1 java]# docker stop heuristic_carson
heuristic_carson
[root@docker--1 java]# docker rm heuristic_carson
heuristic_carson
[root@docker--1 java]# docker ps --all
CONTAINER ID   IMAGE          COMMAND                   CREATED       STATUS       PORTS                                                  NAMES
48fd8551ec83   mysql:5.7.44   "docker-entrypoint.s…"   2 hours ago   Up 2 hours   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   flamboyant_nash
d3a039010bf1   java:v0        "/bin/bash"               5 hours ago   Up 5 hours   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   6 hours ago   Up 6 hours   0.0.0.0:80->80/tcp, :::80->80/tcp                      thirsty_babbage
[root@docker--1 java]# vim Dockerfile 
[root@docker--1 java]# vim start.sh
[root@docker--1 java]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
java         v1        8738b8a36bf9   33 minutes ago   591MB
java         v0        cf1a38ea2001   5 hours ago      774MB
nginx        latest    5ef79149e0ec   2 weeks ago      188MB
mysql        5.7.44    5107333e08a8   8 months ago     501MB
centos       latest    5d0da3dc9764   2 years ago      231MB
[root@docker--1 java]# docker ps --all
CONTAINER ID   IMAGE          COMMAND                   CREATED       STATUS       PORTS                                                  NAMES
48fd8551ec83   mysql:5.7.44   "docker-entrypoint.s…"   2 hours ago   Up 2 hours   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   flamboyant_nash
d3a039010bf1   java:v0        "/bin/bash"               5 hours ago   Up 5 hours   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   6 hours ago   Up 6 hours   0.0.0.0:80->80/tcp, :::80->80/tcp                      thirsty_babbage
[root@docker--1 java]# docker rmi java:v1
Untagged: java:v1
Deleted: sha256:8738b8a36bf97b7066911888fcc6ccfde793b4f42892be3fe770551daf8365c4
[root@docker--1 java]# docker build -t java:v1 .
[+] Building 0.6s (11/11) FINISHED                                    docker:default=> [internal] load build definition from Dockerfile                            0.0s=> => transferring dockerfile: 309B                                            0.0s=> [internal] load metadata for docker.io/library/centos:latest                0.0s=> [internal] load .dockerignore                                               0.0s=> => transferring context: 2B                                                 0.0s=> [1/7] FROM docker.io/library/centos:latest                                  0.0s=> [internal] load build context                                               0.0s=> => transferring context: 25.93kB                                            0.0s=> CACHED [2/7] ADD application.properties /application.properties             0.0s=> CACHED [3/7] ADD jdk /usr/local/jdk/                                        0.0s=> CACHED [4/7] ADD Project_ExamSystem-V1.0.0.war /Project_ExamSystem-V1.0.0.  0.0s=> [5/7] ADD start.sh /start.sh                                                0.0s=> [6/7] RUN chmod -v +x /start.sh                                             0.4s=> exporting to image                                                          0.0s=> => exporting layers                                                         0.0s=> => writing image sha256:cbe450fc552275f01d345fcbb348099cced02d0e5d00ae4813  0.0s=> => naming to docker.io/library/java:v1                                      0.0s
[root@docker--1 java]# docker run -itd -p8081:8080 java:v1
5fc4bd6c574f58aee7c7ad560e8f8189b94324369c54c0e11adb2b16e0921058
[root@docker--1 java]# docker ps 
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS          PORTS                                                  NAMES
5fc4bd6c574f   java:v1        "/start.sh /bin/bash"     12 seconds ago   Up 11 seconds   0.0.0.0:8081->8080/tcp, :::8081->8080/tcp              kind_easley
48fd8551ec83   mysql:5.7.44   "docker-entrypoint.s…"   2 hours ago      Up 2 hours      0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   flamboyant_nash
d3a039010bf1   java:v0        "/bin/bash"               5 hours ago      Up 5 hours      0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              quirky_bell
7c7f8bbb4ae7   nginx:latest   "/docker-entrypoint.…"   6 hours ago      Up 6 hours      0.0.0.0:80->80/tcp, :::80->80/tcp                      thirsty_babbage
[root@docker--1 java]# 

这篇关于部署project_exam_system项目——及容器的编排的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1126904

相关文章

闲置电脑也能活出第二春?鲁大师AiNAS让你动动手指就能轻松部署

对于大多数人而言,在这个“数据爆炸”的时代或多或少都遇到过存储告急的情况,这使得“存储焦虑”不再是个别现象,而将会是随着软件的不断臃肿而越来越普遍的情况。从不少手机厂商都开始将存储上限提升至1TB可以见得,我们似乎正处在互联网信息飞速增长的阶段,对于存储的需求也将会不断扩大。对于苹果用户而言,这一问题愈发严峻,毕竟512GB和1TB版本的iPhone可不是人人都消费得起的,因此成熟的外置存储方案开

这15个Vue指令,让你的项目开发爽到爆

1. V-Hotkey 仓库地址: github.com/Dafrok/v-ho… Demo: 戳这里 https://dafrok.github.io/v-hotkey 安装: npm install --save v-hotkey 这个指令可以给组件绑定一个或多个快捷键。你想要通过按下 Escape 键后隐藏某个组件,按住 Control 和回车键再显示它吗?小菜一碟: <template

如何用Docker运行Django项目

本章教程,介绍如何用Docker创建一个Django,并运行能够访问。 一、拉取镜像 这里我们使用python3.11版本的docker镜像 docker pull python:3.11 二、运行容器 这里我们将容器内部的8080端口,映射到宿主机的80端口上。 docker run -itd --name python311 -p

阿里开源语音识别SenseVoiceWindows环境部署

SenseVoice介绍 SenseVoice 专注于高精度多语言语音识别、情感辨识和音频事件检测多语言识别: 采用超过 40 万小时数据训练,支持超过 50 种语言,识别效果上优于 Whisper 模型。富文本识别:具备优秀的情感识别,能够在测试数据上达到和超过目前最佳情感识别模型的效果。支持声音事件检测能力,支持音乐、掌声、笑声、哭声、咳嗽、喷嚏等多种常见人机交互事件进行检测。高效推

在cscode中通过maven创建java项目

在cscode中创建java项目 可以通过博客完成maven的导入 建立maven项目 使用快捷键 Ctrl + Shift + P 建立一个 Maven 项目 1 Ctrl + Shift + P 打开输入框2 输入 "> java create"3 选择 maven4 选择 No Archetype5 输入 域名6 输入项目名称7 建立一个文件目录存放项目,文件名一般为项目名8 确定

Vue3项目开发——新闻发布管理系统(六)

文章目录 八、首页设计开发1、页面设计2、登录访问拦截实现3、用户基本信息显示①封装用户基本信息获取接口②用户基本信息存储③用户基本信息调用④用户基本信息动态渲染 4、退出功能实现①注册点击事件②添加退出功能③数据清理 5、代码下载 八、首页设计开发 登录成功后,系统就进入了首页。接下来,也就进行首页的开发了。 1、页面设计 系统页面主要分为三部分,左侧为系统的菜单栏,右侧

K8S(Kubernetes)开源的容器编排平台安装步骤详解

K8S(Kubernetes)是一个开源的容器编排平台,用于自动化部署、扩展和管理容器化应用程序。以下是K8S容器编排平台的安装步骤、使用方式及特点的概述: 安装步骤: 安装Docker:K8S需要基于Docker来运行容器化应用程序。首先要在所有节点上安装Docker引擎。 安装Kubernetes Master:在集群中选择一台主机作为Master节点,安装K8S的控制平面组件,如AP

Spring框架5 - 容器的扩展功能 (ApplicationContext)

private static ApplicationContext applicationContext;static {applicationContext = new ClassPathXmlApplicationContext("bean.xml");} BeanFactory的功能扩展类ApplicationContext进行深度的分析。ApplicationConext与 BeanF

SpringBoot项目是如何启动

启动步骤 概念 运行main方法,初始化SpringApplication 从spring.factories读取listener ApplicationContentInitializer运行run方法读取环境变量,配置信息创建SpringApplication上下文预初始化上下文,将启动类作为配置类进行读取调用 refresh 加载 IOC容器,加载所有的自动配置类,创建容器在这个过程

Maven创建项目中的groupId, artifactId, 和 version的意思

文章目录 groupIdartifactIdversionname groupId 定义:groupId 是 Maven 项目坐标的第一个部分,它通常表示项目的组织或公司的域名反转写法。例如,如果你为公司 example.com 开发软件,groupId 可能是 com.example。作用:groupId 被用来组织和分组相关的 Maven artifacts,这样可以避免