package com.example.springboot.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
http://127.0.0.1/hello
本地cmd测试
java -jar demo-0.0.1-SNAPSHOT.jar
FROM java:8
COPY *.jar /app.jar
CMD ["--server.port=8080"]
EXPOSE 8080
ENTRYPOINT ["java","-jar","/app.jar"]
上传文件:
docker build -t springboot-hello .
docker run -d -P --name springboot-hello-web springboot-hello
curl localhost:49160/hello
app.py
import time
import redis
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World!'
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080, debug=True)
requirements.txt
flask
dockerfile
# syntax=docker/dockerfile:1
FROM python:3.8-alpine
ADD . /code
WORKDIR /code
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
docker build -t py-test .
docker run -d -p 8080:8080 --name py-test01 py-test
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/zx77588023/article/details/122737990
内容来源于网络,如有侵权,请联系作者删除!