Detailed process of deploying Docker to WSL2 in IDEA

Detailed process of deploying Docker to WSL2 in IDEA

The local environment is Windows 10 + WSL2 (Ubuntu). You need to install Docker on the server and enable remote access.

sudo vi /etc/default/docker modify configuration

# Enable remote access -H tcp://0.0.0.0:2375
# Enable local socket access -H unix:///var/run/docker.sock
DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"

sudo service docker restart restart

After installing the Docker plug-in in Idea, set the address tcp://192.168.50.28:2375 (your local IP address). If the connection is successful, there will be a Connection Successful prompt

insert image description here

To configure the Tools option, you need to install the Windows version of Docker first. After the installation, close the program and turn it off automatically when the computer starts, because I don’t want to open an extra program. Ubuntu already has Docker, so here I just need to use docker-compose.exe to do container orchestration in the Windows environment. Don't worry about Docker Machine if you don't need it.

insert image description here

General Dockerfile and docker-compose.yml file reference

FROM ubuntu:latest

COPY target/*.jar /app.jar

ENV JAVA_HOME="/usr/lib/jdk1.8"

ENV PATH="${PATH}:${JAVA_HOME}/bin:${JAVA_HOME}/sbin"

ENTRYPOINT [ "java", "-jar", "/app.jar" ]
version: '3'
services:
  last:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "18080:8080"
    volumes:
      - /usr/lib/jvm/java-8-openjdk-amd64:/usr/lib/jdk1.8 #Host jdk maps to container using tty: true
    network_mode: bridge
    restart: always

Creating Docker containers using Docker-compose

insert image description here

Compose files Select the docker-compose.yml file you just created

run

Deploying 'Compose: lin-test'...
"C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe" -f D:\Project\gitFile\lin\lin-test\docker-compose.yml up -d
Building last
Sending build context to Docker daemon 61.72MB
Step 1/5: FROM ubuntu:latest
---> c29284518f49
Step 2/5 : COPY target/*.jar /app.jar
---> f13f1a3f4a0d
Step 3/5 : ENV JAVA_HOME="/usr/lib/jdk1.8"
---> Running in ea05d01bf802
Removing intermediate container ea05d01bf802
---> 9bb4f1a6be38
Step 4/5 : ENV PATH="${PATH}:${JAVA_HOME}/bin:${JAVA_HOME}/sbin"
---> Running in 73ab542794a5
Removing intermediate container 73ab542794a5
---> a6d791e7bd7c
Step 5/5 : ENTRYPOINT [ "java", "-jar", "/app.jar" ]
---> Running in e1704a59d50b
Removing intermediate container e1704a59d50b
---> 8ee7a6f5b53a
Successfully built 8ee7a6f5b53a
Successfully tagged lin-test_last:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Image for service last was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating lin-test_last_1 ...
Creating lin-test_last_1 ... done
'Compose: lin-test' has been deployed successfully.

This is the end of this article about deploying Docker to WSL2 with IDEA. For more information about deploying Docker to WSL2 with IDEA, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to make a tar file of wsl through Docker
  • Installing Docker Desktop reports an error message: WSL 2 installation is incomplete (Solve the error message)
  • How to install WSL2 Ubuntu20.04 on Windows 10 and set up the docker environment
  • Tutorial on installing Docker in Windows 10 subsystem Ubuntu (WSL) (with pictures and text)
  • About WSL configuration and modification issues in Docker

<<:  A comparison between the href attribute and onclick event of the a tag

>>:  MySQL quickly inserts 100 million test data

Recommend

Docker volumes file mapping method

background When working on the blockchain log mod...

Linux installation Redis implementation process and error solution

I installed redis today and some errors occurred ...

MySQL database implements OLTP benchmark test based on sysbench

Sysbench is an excellent benchmark tool that can ...

Detailed explanation of writing and using Makefile under Linux

Table of contents Makefile Makefile naming and ru...

Nodejs global variables and global objects knowledge points and usage details

1. Global Object All modules can be called 1) glo...

Circular progress bar implemented with CSS

Achieve results Implementation Code html <div ...

MySQL sequence AUTO_INCREMENT detailed explanation and example code

MySQL sequence AUTO_INCREMENT detailed explanatio...

Detailed explanation of deploying MySQL using Docker (data persistence)

This article briefly describes how to use Docker ...

Summary of methods for inserting videos into HTML pages

Now if you want to use the video tag in a page, y...

Specific usage of fullpage.js full screen scrolling

1.fullpage.js Download address https://github.com...