docker(sentinel和springBoot)

docker(sentinel和springBoot)

sentinel-dashboard

# 拉取镜像
docker pull bladex/sentinel-dashboard
# 启动,这也太简单了吧。
docker run --name cxysentinel -d -p 8858:8858 -d 镜像id

image-20200726101905251

springBoot项目

创建Dockerfile

名字只能是Dockerfile,下面的app.jar按照自己的名字写。或者将自己的jar包名字改成这个。

image-20200728172034258

打包

image-20200728172200435

上传到服务器

[root@centos8 esDocker]# docker build -t es:1.0  . #打包命令,注意点。
Sending build context to Docker daemon  52.22MB
Step 1/5 : FROM java:8
8: Pulling from library/java
5040bd298390: Pull complete 
fce5728aad85: Pull complete 
76610ec20bf5: Pull complete 
60170fec2151: Pull complete 
e98f73de8f0d: Pull complete 
11f7af24ed9c: Pull complete 
49e2d6393f32: Pull complete 
bb9cdec9c7f3: Pull complete 
Digest: sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d
Status: Downloaded newer image for java:8
 ---> d23bdf5b1b1b
Step 2/5 : COPY *.jar /app.jar
 ---> 815e6fde77ae
Step 3/5 : CMD ["--server.port=8080"]
 ---> Running in d51406f8c79f
Removing intermediate container d51406f8c79f
 ---> 83a3ad00809a
Step 4/5 : EXPOSE 8080
 ---> Running in e383231466d2
Removing intermediate container e383231466d2
 ---> f1b82f641b8a
Step 5/5 : ENTRYPOINT ["java","-jar","app.jar"]
 ---> Running in ace034ac06de
Removing intermediate container ace034ac06de
 ---> 4783629031ef
Successfully built 4783629031ef
Successfully tagged es:1.0
[root@centos8 esDocker]# docker images #查看镜像
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
es                  1.0                 4783629031ef        10 seconds ago      695MB
java                8                   d23bdf5b1b1b        3 years ago         643MB
[root@centos8 esDocker]# docker run -d -p 8080:8080 --name cxyes1.0 4783629031ef # 启动镜像
10c397ad2e7610e0d5d018a8a45325dffaad647e62ca49e764c0d742994e16d5
[root@centos8 esDocker]# docker ps # 查看运行的镜像。
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
10c397ad2e76        4783629031ef        "java -jar app.jar -…"   3 minutes ago       Up 3 minutes        0.0.0.0:8080->8080/tcp   cxyes1.0