IDEA部署Docker到WSL2的詳細(xì)過(guò)程
本地環(huán)境 Windows10+WSL2(Ubuntu),需要大家在服務(wù)器安裝 Docker 之后,開(kāi)啟遠(yuǎn)程訪問(wèn)
sudo vi /etc/default/docker 修改配置
# 開(kāi)啟遠(yuǎn)程訪問(wèn) -H tcp://0.0.0.0:2375 # 開(kāi)啟本地套接字訪問(wèn) -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 重啟
Idea 安裝 Docker 插件后,設(shè)置填寫(xiě)地址 tcp://192.168.50.28:2375 (自己的本機(jī) IP 地址),成功連接的話有 Connection Successful 提示

Tools 選項(xiàng)配置,需要先安裝 Windows 版本 Docker,裝完把程序關(guān)掉,開(kāi)機(jī)自啟關(guān)掉,因?yàn)槲也幌攵嚅_(kāi)一個(gè)程序,Ubuntu 里已經(jīng)有 Docker 了,這里只是要用到 docker-compose.exe 在 Windows 環(huán)境做下容器編排而已。Docker Machine 用不著的話不用管。

一般的 Dockerfile 文件和 docker-compose.yml 文件參考
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 #宿主機(jī) jdk 映射給容器使用
tty: true
network_mode: bridge
restart: always
使用 Docker-compose 創(chuàng)建 Docker 容器

Compose files 選擇剛創(chuàng)建的 docker-compose.yml 文件
運(yùn)行
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.
到此這篇關(guān)于IDEA 部署 Docker 到 WSL2的文章就介紹到這了,更多相關(guān)IDEA 部署 Docker WSL2內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
docker中的run/cmd/entrypoint的區(qū)別詳解
Dockerfile中run、cmd和entrypoint都能夠用于執(zhí)行命令,針對(duì)每個(gè)命令給他介紹詳細(xì)用途,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2021-08-08
docker搭建kafka集群的方法實(shí)現(xiàn)
本文主要介紹了docker搭建kafka集群的方法實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05
mysql8.x docker遠(yuǎn)程訪問(wèn)配置詳解
本文主要介紹了mysql8.x docker遠(yuǎn)程訪問(wèn)配置,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-12-12
Docker中conda環(huán)境的導(dǎo)出和導(dǎo)入
現(xiàn)在很多的應(yīng)用程序系統(tǒng)都會(huì)選擇使用docker容器進(jìn)行部署,本文主要介紹了Docker中conda環(huán)境的導(dǎo)出和導(dǎo)入,具有一定的參考價(jià)值,感興趣的可以了解一下2024-02-02

