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

Common functions of MySQL basics

Table of contents 1. Common function classificati...

Detailed explanation of flex and position compatibility mining notes

Today I had some free time to write a website for...

Script example for starting and stopping spring boot projects in Linux

There are three ways to start a springboot projec...

Use of Docker UI, a Docker visualization management tool

1. Introduction to DockerUI DockerUI is based on ...

Vue uses WebSocket to simulate the chat function

The effect shows that two browsers simulate each ...

HTML5+CSS3 coding standards

The Golden Rule No matter how many people are wor...

Example of using nested html pages (frameset usage)

Copy code The code is as follows: <!DOCTYPE ht...

CSS code to achieve 10 modern layouts

Preface I watched web.dev's 2020 three-day li...

HTML+jQuery to implement a simple login page

Table of contents Introduction Public code (backe...

Nginx Layer 4 Load Balancing Configuration Guide

1. Introduction to Layer 4 Load Balancing What is...

Simple usage example of vue recursive component

Preface I believe many students are already famil...