Skip to content

Instantly share code, notes, and snippets.

@gadmel
Last active March 1, 2023 17:10
Show Gist options
  • Save gadmel/f5cdb3cefb4bb4f35ee76c898d1895f3 to your computer and use it in GitHub Desktop.
Save gadmel/f5cdb3cefb4bb4f35ee76c898d1895f3 to your computer and use it in GitHub Desktop.
Start Docker with environment variable
docker run --env ENV_KEY=env_value -d -p 8080:8080 ImAgE-ID
Dockerfile:
FROM openjdk:19
EXPOSE 8080
WORKDIR /usr/src/myapp
ADD backend/target/app.jar app.jar
CMD ["sh", "-c", "java -jar app.jar", "-Dspring.profiles.active=${ENV_KEY}"]
@Kreyno93
Copy link

Kreyno93 commented Mar 1, 2023

top 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment