I created a small Wildfly Swarm application with a KeyCloak server using the WildFly Swarm Project Generator. I added the code, built and launched my thick jar using:
java -jar -Dswarm.port.offset=100 login-service-swarm.jar
After the application looked, I created new users added to the area, etc. Then I noticed that keycloak created 3 files in my target folders. Those files where:
- keycloak.h2.db
- keycloak.lock.db
- keycloak.trace.db
Then I decided to create docker images and run it in the local docker. So I created a docker file:
FROM java:openjdk-8-jdk ADD login-service-swarm.jar /opt/login-service-swarm.jar ADD keycloak.h2.db /opt/keycloak.h2.db ADD keycloak.lock.db /opt/keycloak.lock.db ADD keycloak.trace.db /opt/keycloak.trace.db EXPOSE 8180 ENTRYPOINT ["java", "-jar", "-Dswarm.port.offset=100", "/opt/login-service-swarm.jar"]
Inline image using:
docker build -f Dockerfile -t login-service-swarm-v1 .
And the image appears in my docker image list:
C:\Work\Java\login-service\docker>docker images REPOSITORY TAG IMAGE ID CREATED SIZE login-service-swarm-v1 latest 710cddc59623 About a minute ago 790 MB <none> <none> 100c0ee60f25 3 hours ago 779 MB demo latest 03d12d49ba5e 4 hours ago 760 MB java openjdk-8-jdk d23bdf5b1b1b 5 months ago 643 MB
So, I started it with:
docker run -p 8180:8180 login-service-swarm-v1
And it looked fine, but when I go to localhost: 8180 / auth and try to log in, I get the wrong username and password, so I can not enter keycloak. So I wonder why this is? Because I included the keycloak database files in the docker image, and if I ran the following commands, you will see that all the files are there as expected.
PS C:\> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8bb4bdb3945e login-service-swarm-v1 "java -jar -Dswarm..." 2 minutes ago Up 2 minutes 0.0.0.0:8180->8180/tcp blissful_knuth PS C:\> docker exec -it 8bb4bdb3945e bash root@8bb4bdb3945e :/
So where is the catch?
docker dockerfile keycloak wildfly-swarm
Kiki
source share