Docker Desktop Installation on Windows 10
When installing Docker Desktop on Windows 10, you may encounter a compatibility error:
We've detected that you have an incompatible version of Windows.
Docker Desktop requires Windows 10 Pro/Enterprise/Home version 19044 or above.
This indicates the Windows version does not meet Docker Desktop's minimum requirements. Download an older compatible version from the official Docker repository or use a Chinese mirror if needed.
After installation, configure IDEA to connect to Docker through the Docker for Windows adapter when generating images.
Setting Up Docker Plugin in IntelliJ IDEA
Install the official Docker integration plugin directly from the IntelliJ IDEA marketplace. This plugin enables direct Docker operations within the IDE.
Creating the Dockerfile
Create a docker folder in the project root directory, then create a Dockerfile file inside it:
FROM openjdk:8-jre
LABEL maintainer="appteam"
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
VOLUME /home/appuser
RUN mkdir -p /home/appuser
WORKDIR /home/appuser
COPY ./service.jar /home/appuser/service.jar
RUN mkdir -p /home/appuser/logs
CMD ["java", "-Xss2M", "-jar", "service.jar", ">>", "/home/appuser/logs/out.txt", "2>>", "/home/appuser/logs/error.txt"]
This Dockerfile:
- Uses OpenJDK 8 JRE as the base image
- Sets the timezone to Asia/Shanghai
- Creates the application directory and working directory
- Copies the JAR file into the container
- Creates a logs directory
- Defines the startup command with output/error logging
Preparing the JAR File
Copy the built JAR file to the same directory as the Dockerfile:
copy "..\..\service-module\target\service.jar" .
Adjust the relative path according to your project structure.
Configuring Docker Environment in IDEA
Enable the Docker plugin and configure the Docker daemon connection in IDEA settings. Point it to the Docker for Windows instance to enable IDE-based Docker operations.
Building the Docker Image
Navigate to the Dockerfile directory and execute the build command:
docker build -t myapp:1.0.0 .
Parameters explained:
myapp- repository name1.0.0- tag version.- current directory containing the Dockerfile
Build output:
[+] Building 2.3s (11/11) FINISHED
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 952B
=> [internal] load .dockerignore
=> => transferring context: 2B
=> [internal] load metadata for docker.io/library/openjdk:8-jre
=> [1/6] FROM docker.io/library/openjdk:8-jre
=> [internal] load build context
=> => transferring context: 299.85MB
=> => writing image sha256:0e42a9e01330eea9622eb57adac43322b71783eed723e85c2e4ac6e574800479
=> => naming to docker.io/library/myapp:1.0.0
Verify the image:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myapp 1.0.0 0e42a9e01330 42 minutes ago 573MB
openjdk 8-jre 0c14a0e20aa3 20 months ago 274MB
Exporting the Image as a TAR File
Export the image to a tar archive for transfer to production environments:
docker save -o myapp.tar myapp:1.0.0
The docker save command exports the specified image with its tag to a single tar file. The -o flag specifies the output filename.
Importing the Image on Production Server
Load the exported image on the target server:
docker load -i myapp.tar
Running the Container
Use the following script to start the container with volume mounts:
#!/bin/bash
docker run -d \
--name myservice \
-p 8080:8080 \
-v /home/appuser/uploadPath:/home/appuser/uploadPath \
-v /home/appuser/logs:/home/appuser/logs \
-v /home/appuser/application.yml:/home/appuser/application.yml \
myapp:1.0.0
echo "Checking container startup logs..."
sleep 3
docker logs myservice
The container is configured with:
- Name:
myservice - Port mapping: host 8080 to container 8080
- Three volume mounts for persistent data, logs, and configuration