So, the image I uploaded to the conter does not display.
Here are the steps I took, and I’ll add right away that I used gradle.
- I downloaded the Docker plugin to IntelliJ
- I created a Dockerfile in which I put:
-
In the terminal, I typed the following commands to build the project:
-
Then I typed (to create an image and display it):
-
And here is where the problem arises, I entered the following commands:
(I want to run on port
8081
because my app listens on port8080
. I don’t know if it matters but that’s how I did it)
I display the list using command: docker container ps
I have no idea what I’m doing wrong that it’s not working, where I’m making a mistake. Is there something else I should do? In general, the spring boot application at this time should be running? What does it look like, I read some tutorials but unfortunately nothing helped, and I was doing the same way as them
3
Answers
You can also create a Docker image with Maven plugin by defining in pom.xml and run ‘mvn install’:
Can you try this instead of manually creating a Dockerfile ?
try to run:
i add a link to my repo which explain about that, in maven docker with spring
A less laborious solution is using Jib under GoogleContainerTools. It is available as a Gradle plugin.
There are alternative options, here are the steps for using Jib Gradle plugin to build a container image and run it:
Add the jib plugin to
build.gradle
:Customize the image build in
build.gradle
:Since your app listens on port 8080, the 8080 port on the container will need to be exposed
Build image from the command line:
Open a command line under the root of your project
3.1. Build image tarball:
This builds and saves your image to
build/jib-image.tar
3.2. Load the image tarball into docker:
Run image as a container from the command line:
Eg:
Here, the 8080 port on the container is mapped to the 8081 port on the host (You can also map it to the 8080 port on the host if you want, the container has its own IP address separate from the host).
More details can be found in the jib-gradle-plugin Quickstart