我需要在手机上为客户端应用程序托管部署 Docker,但目前我已在本地完成。 Jsonlocalhost:8080
根据我的需要返回到机器上的地址,但是当我尝试从ip
机器上的电话+“:8080”连接时,容器不可见,就好像它们无法访问外部网络或一些其他原因。
泊坞窗文件:
FROM maven:3.8.5-openjdk-17 AS build
WORKDIR /app
EXPOSE 8080
COPY target/demo-0.0.1-SNAPSHOT.jar .
CMD ["java", "-jar", "demo-0.0.1-SNAPSHOT.jar"]
docker-撰写:
version: '3.8'
services:
app:
container_name: my-server
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/my_db
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: pass
IMAGE_STORAGE_PATH: /app/images/ # Путь к папке для картинок
volumes:
- ./images:/app/images # Монтируем локальную папку images в контейнер
depends_on:
db:
condition: service_healthy
db:
image: postgres
ports:
- "5432:5432"
environment:
POSTGRES_DB: my_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: pass
healthcheck:
test: [ "CMD-SHELL", "pg_isready", "-d", "my_db" ]
interval: 10s
timeout: 3s
retries: 3