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

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

1.环境准备

[root@docker--1 ~]# rz -E
 
rz waiting to receive.
 
[root@docker--1 ~]# ls
 
anaconda-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
EOF
 
modprobe overlay
 
modprobe br_netfilter
 
cat << 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
EOF
 
sysctl --system
 
yum install -y yum-utils device-mapper-persistent-data lvm2
 
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
 
 
 
yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

2.普通部署

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

3.拉取nginx镜像

[root@docker3 ~]# docker pull nginx
 
Using default tag: latest
 
latest: Pulling from library/nginx
 
Digest: sha256:447a8665cc1dab95b1ca778e162215839ccbb9189104c79d7ec3a81e14577add
 
Status: Image is up to date for nginx:latest
 
docker.io/library/nginx:latest

4.查看镜像

[root@docker3 ~]# docker images
 
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
 
nginx        latest    5ef79149e0ec   2 weeks ago   188MB

5.创建nginx容器

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

[root@docker--1 ~]# docker ps
 
CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS             NAMES
 
a9200f608c60   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 and
 
working. Further configuration is required.</p>
 
<p>For online documentation and support please refer to
 
nginx.org.<br/>
 
Commercial support is available at
 
nginx.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 -E
 
rz waiting to receive.
 
[root@docker--1 web]# ls
 
dist.zip

安装unzip

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

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

[root@docker--1 web]# unzip dist.zip 
 
[root@docker--1 web]# ls
 
dist  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.properties
 
 		      Project_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 -A
 
Database 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.zip
 
5 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 8080
  12 |     
  13 | >>> RUN mkdir /usr/local/jdk
  14 |     
  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/jdk
  14 |     
  15 | >>> RUN tar -zxvf /jdk-17_linux-x64_bin.tar.gz -C /usr/local/jdk --strip-components=1
  16 |     
  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 8080
  12 |     
  13 | >>> RUN mkdir /usr/local/jdk
  14 |     
  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]# 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/872495.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

基于Flink的流式计算可视化开发实践之配置->任务生成->任务部署过程

1. 引言 在我们大数据平台(XSailboat)的DataStudio模块中实现了基于Hive的业务流程开发和基于Flink的实时计算管道开发。 DataStudio是用来进行数据开发的&#xff0c;属于开发环境&#xff0c;另外还有任务运维模块&#xff0c;负责离线分析任务和实时计算任务在生产环境的部…

30岁程序员的焦虑:转行还是继续死磕?现在什么方向更有前景?

最适合转入AI大模型的莫过于程序员和在读大学生了吧。 对于程序员来说&#xff0c;码农之路并不是一帆风顺。对于每一个入行IT业的社会青年来说&#xff0c;谁不是抱着想要成为最高峰的技术大咖或者跃进管理岗的小目标&#xff1f; 然而往往更多的人并非互联网吹捧的如此耀眼…

低代码平台:加速企业制造业数字化转型的新引擎

近期&#xff0c;国家发布了中小企业数字化转型试点城市的政策&#xff0c;旨在通过先行先试&#xff0c;探索支持制造业特别是汽车制造行业数字化转型的有效模式。这一政策的出台&#xff0c;为汽车制造企业的数字化转型提供了强有力的政策支持和方向指引&#xff0c;标志着汽…

【论文速读】| SEAS:大语言模型的自进化对抗性安全优化

本次分享论文&#xff1a;SEAS: Self-Evolving Adversarial Safety Optimization for Large Language Models 基本信息 原文作者: Muxi Diao, Rumei Li, Shiyang Liu, Guogang Liao, Jingang Wang, Xunliang Cai, Weiran Xu 作者单位: 北京邮电大学, 美团 关键词: 大语言模…

vue.js项目实战案例详细源码讲解

​ 大家好&#xff0c;我是程序员小羊&#xff01; 前言&#xff1a; 为帮助大家更好地掌握Vue.js项目的开发流程&#xff0c;我将为你讲解一个完整的Vue.js实战案例&#xff0c;并提供详细的源码解析。这个案例将涵盖从项目创建到实现各种功能模块的全过程&#xff0c;适合用于…

基于空间结构光场照明的三维单像素成像

单像素成像是一种新兴的计算成像技术。该技术使用不具备空间分辨能力的单像素探测器来获取目标物体或场景的空间信息。单像素探测器具有高的时间分辨率、光探测效率和探测带宽&#xff0c;因此单像素光学成像技术在散射、弱光等复杂环境下相较于传统面阵成像技术展现了很大优势…

面试题:软件测试缺陷产生的原因有哪些?

软件缺陷产生的原因多种多样&#xff0c;一般可能有以下几种原因&#xff1a; 1.需求表述、理解、编写引起的错误。 2.系统架构设计引起的错误。 3.开发过程缺乏有效的沟通及监督&#xff0c;甚至没有沟通或监督。 4.程序员编程中产生的错误。 5.软件开发工具本身隐藏的问…

哨兵排序算法

代码展示 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h>#define MAXSIZE 20 //直接排序 typedef struct {int r[MAXSIZE 1];int length; } SqList; int InsertSort(SqList* L) {int i, j;for (i 2; i < L->length; i){if (L-…

mysql自增主键插入后返回id与实际插入id不同

加入这一段即可 GeneratedValue(strategy GenerationType.IDENTITY)

张飞硬件10-TVS管篇笔记

TVS管的原理 TVS或称瞬变电压抑制二极管&#xff0c;是在二极管工艺基础上发展起来的新产品&#xff0c;其电路符号和普通稳压管相同&#xff0c;外形也与普通二极管无异。当TVS管两端经受瞬间的高能量冲击时&#xff0c;它能以极高的速度将其阻抗骤然降低&#xff0c;同时吸收…

el-table 单元格,双击编辑

el-table 单元格&#xff0c;双击编辑 实现效果 代码如下 <template><el-table :data"tableData" style"width: 100%"><el-table-column prop"name" label"姓名" width"180"><template slot-scope&q…

【机器学习】梯度提升和随机森林的概念、两者在python中的实例以及梯度提升和随机森林的区别

引言 梯度提升&#xff08;Gradient Boosting&#xff09;是一种强大的机器学习技术&#xff0c;它通过迭代地训练决策树来最小化损失函数&#xff0c;以提高模型的预测性能 随机森林&#xff08;Random Forest&#xff09;是一种基于树的集成学习算法&#xff0c;它通过组合多…

Java队列详细解释

队列 一、什么是队列&#xff08;Queue&#xff09; java队列是一种线性数据结构&#xff0c;它的特点是先进先出。在队列中&#xff0c;元素的添加&#xff08;入队&#xff09;操作在队尾进行&#xff0c;而元素的移除&#xff08;出队&#xff09;操作则在队头进行。因此&a…

最近大模型最火的就业方向有哪些?

在2023和2024年&#xff0c;大语言模型的发展迎来了绝对风口&#xff0c;吸引了大量创业者和投资者。然而&#xff0c;经过一年的发展&#xff0c;许多公司已经销声匿迹。那么&#xff0c;未来大模型方向上还有哪些可以继续发展的方向呢? 基座大模型预训练 现状 - 展现出“胜…

TikTok Live与跨境电商的深度融合:直播带货引领品牌出海

在TikTok Live的应用中&#xff0c;品牌能够利用这一互动性极强的功能开辟新的销售渠道&#xff0c;推动全球业务的增长。本文Nox聚星将和大家探讨TikTok Live如何与跨境电商相结合&#xff0c;分析其应用场景。 一、TikTok Live与跨境电商的结合优势 庞大的用户基础&#xff…

使用 OpenCV 和 NumPy 进行图像处理:HSV 范围筛选实现PS抠图效果

使用 OpenCV 和 NumPy 进行图像处理&#xff1a;HSV 范围筛选实现PS抠图效果 在计算机视觉和图像处理领域&#xff0c;OpenCV 是一个非常强大的库&#xff0c;能够帮助我们执行各种图像操作。在这篇博客中&#xff0c;我们将通过一个简单的示例演示如何使用 OpenCV 和 NumPy 来…

machine learning - 2

泛化误差 也可以认为是预测时的误差。 训练误差 并不是越小越好&#xff0c;太小会过拟合。 获得测试集合的方法&#xff1a; 1&#xff09;&#xff1a; 2&#xff09;&#xff1a;例如&#xff1a;k-折交叉验证法&#xff0c; 就的每k个数据取一个座位测试集 3&#xff0…

1.39TB高清卫星影像更新(WGS84坐标投影)

最近对WGS84版的高清卫星影像数据进行了一次更新&#xff0c;并基于更新区域生成了相应的接图表。 1.39TB高清卫星影像更新 本次数据更新了1576个离线包&#xff0c;共1.39TB大小&#xff0c;并全部生成了更新接图表。 更新接图表范围 更新接图表由每一个离线包文件的范围构…

rancher upgrade 【rancher 升级】

文章目录 1. 背景2. 下载3. 安装4. 检查5. 测试5.1 创建项目5.2 创建应用5.3 删除集群5.4 注册集群 1. 背景 rancher v2.8.2 升级 v2.9.1 2. 下载 下载charts helm repo add rancher-latest https://releases.rancher.com/server-charts/latest helm repo update helm fetc…

支付宝开放平台-开发者社区——AI 日报「9 月 6 日」

1 3天把Llamaill成Mamba&#xff0c; 性能不降&#xff0c;推理更快&#xff01; 新智元 丨阅读原文 康奈尔和普林斯顿的研究人员成功将大型Transformer模型Llama提炼成Mamba模型&#xff0c;并设计了新的推测解码算法&#xff0c;显著提高了模型的推理速度。研究团队采用了渐…