docker部署project-exam-system项目

news2024/11/15 8:12:43

8月30日笔记

项目实战:使用docker部署project-exam-system

1、背景:

使用基础的docker指令来创建镜像,实现项目的发布,使用Dockderfile,docker compose编排容器。  

2、环境准备:

(1)主机 dokcer01(192.168.2.80)

(2)部署docker环境,执行脚本,参照之前的文章

[root@dokcer01 ~]# vim /etc/docker/daemon.json

{

        "registry-mirrors": [

"https://do.nark.eu.org",

        "https://dc.j8.work",

        "https://docker.m.daocloud.io",

        "https://dockerproxy.com",

        "https://docker.mirrors.ustc.edu.cn",

        "https://docker.nju.edu.cn"

        ]

}

[root@dokcer01 ~]#systemctl restart docker

3、普通部署
#####前端:nginx latest服务######

# 拉取nginx镜像

[root@dokcer01 ~]#docker pull nginx

[root@dokcer01 ~]# docker images

REPOSITORY   TAG       IMAGE ID       CREATED       SIZE

nginx        latest    5ef79149e0ec   2 weeks ago   188MB

centos       latest    5d0da3dc9764   2 years ago   231MB

# 创建nginx容器

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

f4905bfc0a85b7d61b6b0e5e67332ad53283d39a9dac37be209e25db69fe5624

[root@dokcer01 ~]# docker ps

CONTAINER ID   IMAGE          COMMAND                   CREATED         STATUS         PORTS                               NAMES

f4905bfc0a85   nginx:latest   "/docker-entrypoint.…"   8 seconds ago   Up 8 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   practical_keldysh

# 访问测试

[root@dokcer01 ~]# curl localhost

# 查看资源文件

[root@dokcer01 ~]# docker ps

[root@dokcer01 ~]# docker exec -it f4905bf ls /usr/share/nginx/html

# 创建目录,不单独放置前端的资料,将后端所有资料都放在此处 mkdir

[root@dokcer01 ~]# mkdir project_exam_system

[root@dokcer01 ~]# cd project_exam_system/

[root@dokcer01 project_exam_system]# mkdir web

[root@dokcer01 project_exam_system]# ls web/dist/

assets  favicon.ico  index.html

# 停掉并移除容器

[root@dokcer01 project_exam_system]# docker stop f4905b

f4905b

[root@dokcer01 project_exam_system]# docker rm f4905bf4905b

f4905b

# 再创建容器(映射端口及挂载目录)

[root@dokcer01 ~]# docker run -itd centos:latest /bin/bash

675fca4c734a3abce237dae8391a507f2ac2be6438a318b083788f04af01d78c

# 测试成功,但出现问题,实现登录的时候出现后端异常,因为还没部署后端

# 设置域名劫持,在真机的hosts文件中添加域名来实现登录的时候请求的域名ks.tangpin.huajuan

#####后端:jdk17 springboot(不单独部署tomcat,已经在springboot中内置tomcat)###### 

# 拉取基础centos镜像

[root@dokcer01 project_exam_system]# docker pull centos

# jdk17版本文件

[root@dokcer01 project_exam_system]# docker images

REPOSITORY   TAG       IMAGE ID       CREATED       SIZE

nginx        latest    5ef79149e0ec   2 weeks ago   188MB

centos       latest    5d0da3dc9764   2 years ago   231MB

# 启动镜像生成容器

[root@dokcer01 ~]# docker run -itd centos:latest /bin/bash

675fca4c734a3abce237dae8391a507f2ac2be6438a318b083788f04af01d78c

# 上传项目并移动资源文件,application.properties和Project_ExamSystem-V1.0.0.war,先上传到/root下,再移动到dokcer中

[root@docker~]#scp -r dist/ root@192.168.2.80:~/project_exam_system/web/

[root@dokcer01 ~]# ls

anaconda-ks.cfg

application.properties

docker.sh

huajuan.tar

jdk-17_linux-x64_bin.tar.gz

project_exam_system

Project_ExamSystem-V1.0.0.war

Soft

[root@dokcer01 ~]# docker cp application.properties 675fca:/

Successfully copied 4.1kB to 675fca:/

[root@dokcer01 ~]# docker cp Project_ExamSystem-V1.0.0.war 675fca:/

Successfully copied 41MB to 675fca:/

[root@dokcer01 ~]# docker cp jdk-17_linux-x64_bin.tar.gz 675fca:/

Successfully copied 183MB to 675fca:/

# 检查是否移动成功

[root@dokcer01 ~]# docker attach 675fca

[root@675fca4c734a /]# ls

Project_ExamSystem-V1.0.0.war  lib64    sbin

application.properties        lost+found  srv

bin        media    sys

dev        mnt    tmp

etc        opt    usr

home        proc    var

jdk-17_linux-x64_bin.tar.gz    root

lib

# 跳过一层目录进行解压

[root@675fca4c734a /]# mkdir /usr/local/jdk

[root@675fca4c734a /]# tar -zxvf jdk-17_linux-x64_bin.tar.gz -C /usr/local/jdk/ --strip-components=1

# 修改application文件

[root@675fca4c734a /]# vi application.properties

spring.datasource.url=jdbc:mysql://192.168.2.80:3306/project_exam_system

                                  【宿主机ip】  【数据库名称】

spring.datasource.username=zhangmin

spring.datasource.password=zhangmin

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# 启动服务

[root@675fca4c734a /]# /usr/local/jdk/bin/java -jar Project_ExamSystem-V1.0.0.war

# 测试

[root@dokcer01 ~]# curl 192.168.2.80:8080

# 使用容器创建镜像

[root@dokcer01 ~]# docker commit 675fca java:v0

sha256:e9e25e9b727960b24f09a0ad7736abacb2f4d9cd9bf02a2164deeee7862c71eb

[root@dokcer01 ~]# docker images

REPOSITORY   TAG       IMAGE ID       CREATED         SIZE

java         v0        e9e25e9b7279   5 seconds ago   775MB

nginx        latest    5ef79149e0ec   2 weeks ago     188MB

centos       latest    5d0da3dc9764   2 years ago     231MB

# 移除旧容器,使用新的java镜像创建容器(映射端口)

[root@dokcer01 ~]# docker stop 675fca

675fca

[root@dokcer01 ~]# docker rm 675fca

675fca

[root@dokcer01 ~]# docker run -itd -p8080:80 java:v0

c4cbff0183e0fa8c49e5cad170f30a6dc01d93a1f23c6ebe9874af9547d78614

# 查看进程

[root@dokcer01 ~]#docker ps

[root@dokcer01 ~]# docker attach c4cbff

[root@dokcer01 /]# /usr/local/jdk/bin/java -jar Proje

ct_ExamSystem-V1.0.0.war

遇到的报错!!!

docker:Error response from daemon:driver failed programming external connectivity on endpoint xxxx

例如:来自daemon的错误响应:驱动程序在端点上的外部连接编程失败

解决方案:

提示:重启docker  systemctl restart docker

# 测试,显示账号密码不存在,出现500表明java服务配置成功

[root@dokcer01 ~]# curl 192.168.2.80:8080

{"code":20002,"msg":"账号不存在或密码错误"}[root@dokcer01 ~]#

#####mysql服务######

# 拉取mysql:5.7.44

[root@dokcer01 ~]#docker pull mysql:5.7.44

[root@dokcer01 ~]# docker images

mysql        5.7.44    5107333e08a8   8 months ago   501MB

# 上传sql语句到/root目录下

[root@dokcer01 ~]# ls 

project_exam_system.sql

# 启动数据库

[root@dokcer01 ~]#docker run -itd -e MYSQL_ROOT_PASSWORD=ROOT -p 3306:3306 mysql:5.7.44

01f24510a17fde44cab63bfb13ac7c55cf8f0a7bdfbbc038bae059d0eff0a466

# 查看所有容器

[root@dokcer01 ~]# docker ps -a

CONTAINER ID   IMAGE          COMMAND                   CREATED          STATUS                   PORTS                                                  NAMES

01f24510a17f   mysql:5.7.44   "docker-entrypoint.s…"   15 seconds ago   Up 13 seconds

# 取出/data目录数据库  

[root@dokcer01 ~]# docker cp 01f24:/var/lib/mysql project_exam_system/

Successfully copied 220MB to /root/project_exam_system/

[root@dokcer01 ~]# cd project_exam_system/

[root@dokcer01 project_exam_system]# ls

mysql  web

[root@dokcer01 project_exam_system]# cd mysql/

# 删除存在的mysql目录,重新创建mysql目录

[root@dokcer01 mysql]# rm -rf mysql/

[root@dokcer01 mysql]# mkdir mysql

[root@dokcer01 mysql]# ls

[root@dokcer01 mysql]# mv project_exam_system.sql mysql/

[root@dokcer01 mysql]# ls mysql/

project_exam_system.sql

[root@dokcer01 mysql]# pwd

/root/project_exam_system/mysql

# 将sql上传到mysql容器中  

[root@dokcer01 ~]# docker cp project_exam_system/mysql/project_exam_system.sql 01f24:/

Successfully copied 11MB to 01f24:/

ebf32bf6e6b3e52521355cbc1fa6b0a3fa3acb01740d68363bc9a1768ae26d6d

[root@dokcer01 ~]# docker attach 01f24

# 使用exec指令访问数据库管理界面,查看是否有数据库

[root@dokcer01 ~]#mysql -uroot -proot < project_exam_system.sql

# 启动mysql容器并映射端口

docker run -itd -p3306:3306 mysql:5.7.44

[root@dokcer01 ~]#docker exec -it 01f24 mysql -uroot -root

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 'huajuan'@'%' identified by 'huajuan';
Query OK, 0 rows affected (0.01 sec)
 
mysql> grant all on *.* to 'huajuan'@'%';
Query OK, 0 rows affected (0.00 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> exit
Bye

#####使用Dockerfile文件进行编排###### 

[root@docker01 ~]# 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@docker01 ~]# 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@docker01 ~]# mkdir project_exam_system/java

[root@docker01 ~]# mv jdk-17_linux-x64_bin.tar.gz project_exam_system/java/

[root@docker01 ~]# mv application.properties project_exam_system/java/

[root@docker01 ~]# mv Project_ExamSystem-V1.0.0.war project_exam_system/java/

[root@docker01 ~]# ls

anaconda-ks.cfg  docker.sh  mysql  project_exam_system

[root@docker01 ~]# 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@docker01 ~]# cd project_exam_system/java/

[root@docker01 java]# rz -E

rz waiting to receive.

[root@docker01 java]# ls

application.properties  jdk-17_linux-x64_bin.tar.gz

Dockerfile              Project_ExamSystem-V1.0.0.war

[root@docker01 java]# docker build -t java:v1 .

[root@docker01 java]# ls

application.properties  jdk-17_linux-x64_bin.tar.gz

Dockerfile              Project_ExamSystem-V1.0.0.war

[root@docker01 java]# tar -zxvf jdk-17_linux-x64_bin.tar.gz

[root@docker01 java]# ls

application.properties  jdk-17.0.12                  Project_ExamSystem-V1.0.0.war

Dockerfile              jdk-17_linux-x64_bin.tar.gz

[root@docker01 java]# mv jdk-17.0.12/ jdk

[root@docker01 java]# ls

application.properties  jdk                          Project_ExamSystem-V1.0.0.war

Dockerfile              jdk-17_linux-x64_bin.tar.gz

[root@docker01 java]# vim Dockerfile

[root@docker01 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@docker01 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@docker01 java]# vim Dockerfile

[root@docker01 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@docker01 java]# vim Dockerfile

[root@docker01 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@docker01 java]# vim Dockerfile

[root@docker01 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@docker01 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@docker01 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@docker01 java]# docker run -itd -p8081:8080 java:v1 /bin/bash

a3c4fbc92430316aae70755992d76c3d1d2868560f61e1cbbfb5dc57eb93cd4b

[root@docker01 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@docker01 java]# docker stop 037

037

[root@docker01 java]# docker rm 037

037

[root@docker01 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@docker01 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@docker01 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@docker01 java]# docker stop heuristic_carson

heuristic_carson

[root@docker01 java]# docker rm heuristic_carson

heuristic_carson

[root@docker01 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@docker01 java]# vim Dockerfile

[root@docker01 java]# vim start.sh

[root@docker01 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@docker01 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@docker01 java]# docker rmi java:v1

Untagged: java:v1

Deleted: sha256:8738b8a36bf97b7066911888fcc6ccfde793b4f42892be3fe770551daf8365c4

[root@docker01 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@docker01 java]# docker run -itd -p8081:8080 java:v1

5fc4bd6c574f58aee7c7ad560e8f8189b94324369c54c0e11adb2b16e0921058

[root@docker01 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

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

sts 0/1 没有 pod生成 -> kube-controller-manager没了

kube-controller-manager.yaml 在 nerdctl ps -a 看不到 journalctl -xu kubelet > /tmp/kubelet.log /tmp/kubelet.log 老6

OpenSetting组件的用法

文章目录 1. 概念介绍2. 使用方法与主要功能2.1 使用方法2.2 主要功能 3. 示例代码4. 内容总结 我们在上一章回中介绍了"如何获取App自身信息"相关的内容&#xff0c;本章回中将介绍一个三方包:open_setting.闲话休提&#xff0c;让我们一起Talk Flutter吧。 1. 概念…

JavaWeb:实验二JSP表单开发及访问数据库

一、实验目的 1&#xff0e;掌握JSP表单的开发方法。 2&#xff0e;熟悉JDBC技术和使用JDBC连接各种数据库。 二、实验性质 综合性实验 三、实验内容 实现注册与登录功能&#xff1a; 1.创建一个数据库&#xff0c;在数据库建立用户表。&#xff08;5分&#xff09; 2…

城市管理违规行为智能识别 Task3学习心得

本次学习主要针对数据集增强和模型预测 1、数据增强&#xff1a; 1&#xff09;将四张训练图像组合成一张&#xff0c;增加物体尺度和位置的多样性。 2&#xff09;复制一个图像的随机区域并粘贴到另一个图像上&#xff0c;生成新的训练样本 3&#xff09;图像的随机旋转、…

day25 Java基础——面向对象两万字详解!(纯干货)

day25 Java基础——面向对象两万字详解&#xff01;&#xff08;纯干货&#xff09; 文章目录 day25 Java基础——面向对象两万字详解&#xff01;&#xff08;纯干货&#xff09;1. 类与对象的关系类&#xff08;Class&#xff09;对象&#xff08;Object&#xff09;类与对象…

gitee绑定公钥后依旧无法使用_gitee push添加公钥无效

解决&#xff1a; 步骤按照官网操作即可&#xff1a;gitee官方说明 看看远程地址是否使用的http模式&#xff0c;是的话换ssh模式

Adobe Acrobat Reader的高级功能详解

​ 大家好&#xff0c;我是程序员小羊&#xff01; 前言&#xff1a; Adobe Acrobat Reader是广泛使用的PDF查看器&#xff0c;其不仅可以用于查看和打印PDF文件&#xff0c;还具有一些高级功能&#xff0c;可以提升用户的PDF文档处理效率。以下是对Adobe Acrobat Reader的一些…

RH850系列芯片深度剖析 1.7-启动流程解析

RH850系列芯片深度剖析 1.7-启动流程解析 文章目录 RH850系列芯片深度剖析 1.7-启动流程解析一、简介二、启动相关文件说明三、启动相关的段四、启动流程4.1 启动文件启动4.1.1 寄存器初始化4.1.2 时钟初始化4.1.3 模块Standby寄存器初始化4.1.4 启动从核4.1.5 硬件初始化4.1.5…

vector模拟实现迭代器失效

目录 1.vector和vector> 1.1两者的区别 1.2遍历的方法 2.vector模拟实现的准备 3.reserve出现的问题及解决方案 4.遍历vector的三种方式 5.关于typename的使用 6.insert导致的迭代其实失效问题 6.1因为扩容导致的迭代器失效 6.2因为插入数据倒置的迭代器失效 1.vec…

【精彩回顾·成都】成都 UG 生成式 AI 工作坊:AI 革命下的商业模式创新!

文章目录 前言一、活动介绍二、精彩分享内容及活动议程2.1、亚马逊云科技社区情况和活动介绍2.2、《浅谈 AIGC 商业化》2.3、《AI 浪潮下的产品落地》2.4、现场互动情况2.5、休息茶歇时间2.6、《AI 赋能商业革新&#xff1a;智能化转型的策略与实践》2.7、《动手实践&#xff1…

GAMES104:10+11游戏引擎中物理系统的基础理论算法和高级应用-学习笔记

文章目录 概览一&#xff0c;物理对象与形状1.1 对象 Actor1.2 对象形状Actor Shape 二&#xff0c;力与运动2.1 牛顿定律2.2 欧拉法2.2.1 显式欧拉法Explicit (Forward) Euler’s Method2.2.2 隐式欧拉法 Implicit (Backward) Euler’s Method2.2.3 半隐式欧拉法 Semi-implici…

【iOS】通过第三方库Masonry实现自动布局

目录 前言 约束 添加约束的规则 使用Masonry自动布局 Masonry的常见使用方法 补充 前言 在暑期完成项目时&#xff0c;经常要花很多时间在调试各种控件的位置上&#xff0c;因为每一个控件的位置都需要手动去计算&#xff0c;在遇到循环布局的控件时&#xff0c;还需要设…

使用文件系统管理硬件设备

1、描述一个文件系统 介绍如何使用文件系统来管理计算机系统中所有的硬件设计和磁盘 之前直接在sys_open/sys_read/sys_read中对具体的tty设备的打开、读写进行操作&#xff0c;并且只是非常粗浅地介绍了文件系统的一些概念。接下来将正式引入文件系统 由于文件系统需要考虑不…

从FasterTransformer源码解读开始了解大模型(2.4)代码通读05

从FasterTransformer源码解读开始了解大模型&#xff08;2.4&#xff09;代码解读05-ContextDecoder的前向01 写在前面的话 ContextDecoder部分是用于处理输入部分的组件层&#xff0c;在这一层中&#xff0c;会对所有输入的input ids进行处理&#xff0c;计算Attention&…

全国大学生数学建模比赛——关联规则

一、问题背景与关联规则适用性 在数学建模比赛中&#xff0c;常常会遇到需要分析大量数据以寻找变量之间潜在关系的问题。关联规则分析作为一种数据挖掘技术&#xff0c;特别适用于这种场景。例如&#xff0c;在一些实际问题中&#xff0c;可能需要从众多的因素中找出哪些因素之…

基于Python的量化交易回测框架Backtrader初识记录(一)

版权声明&#xff1a;本文为博主原创文章&#xff0c;如需转载请贴上原博文链接&#xff1a;基于Python的量化交易回测框架Backtrader初识记录&#xff08;一&#xff09;-CSDN博客 前言&#xff1a;近期以来&#xff0c;对股市数据获取及预处理算是告一段落&#xff0c;下一步…

Java-多线程机制

上篇我提到一些多线程的基本使用方法&#xff0c;但并没有说到底层原理&#xff0c;你或许会有一些疑问&#xff0c;为什么不直接调用Run方法而是要用start方法启动线程&#xff1f;多线程到底是怎样执行的&#xff1f;接下来我会详细带你了解多线程的机制原理。 多线程的底层…

Leetcode114将二叉树转换为链表(java实现)

来看下本题的题目描述&#xff1a; 本题想让我们将二叉树转换为单链表&#xff0c;可以发现&#xff0c;左边的二叉树转换为右边的链表是使用的中序遍历&#xff0c;根 左 右 所以本道题的思路就是可以先用一个集合以中序遍历收集元素&#xff0c;然后再构建单链表。 class S…

[pytorch] --- pytorch基础之tensorboard使用

0 tensorboard介绍 TensorBoard是一个用于可视化机器学习实验结果的工具&#xff0c;可以帮助我们更好地理解和调试训练过程中的模型。 在PyTorch中&#xff0c;我们可以使用TensorBoardX库来与TensorBoard进行交互。TensorBoardX 是一个PyTorch的扩展&#xff0c;它允许我们…

Android Codec2 CCodec (七)IConfigurable

上一篇文章我们了解了接口参数的定义&#xff0c;这一节我们简单梳理一下参数获取、配置以及参数反射过程。 1、IConfigurable 通过之前的介绍我们了解到&#xff0c;Codec2模块的功能实现与配置实现是相互分离的&#xff0c;Codec2框架设计了一组API用于获取与模块关联的配置…