Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
관리 메뉴

말랑코딩

vscode에서 원격 서버의 docker container에 접속하기 본문

Linux, Docker, Git

vscode에서 원격 서버의 docker container에 접속하기

코랑이 2022. 1. 25. 14:59

기존 나의 환경

- 원격서버

- docker 로 작업

- ubuntu 환경

- 툴은 mobaXterm 사용 ---> vscode로 바꾸고 싶음 (.py 등의 파일을 열 수 없어서)

 

 

vscode 에서 원격서버의 도커 접속 방법

1. 윈도우에서 vscode 다운로드

https://code.visualstudio.com/download

 

Download Visual Studio Code - Mac, Linux, Windows

Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications.

code.visualstudio.com

2. 윈도우에서 도커 다운로드

https://docs.docker.com/docker-for-windows/install/

 

Redirecting…

 

docs.docker.com

3. Remote-Containers라는 extension을 설치

https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers

 

Remote - Containers - Visual Studio Marketplace

Extension for Visual Studio Code - Open any folder or repository inside a Docker container and take advantage of Visual Studio Code's full feature set.

marketplace.visualstudio.com

 

 

4. 모두 설치한 이후에 할일

 

vscode 에서 settings.json 파일 수정해야함

F1 누르고 - setting 입력하면 아래 파일이 뜸. 클릭

 

위에 내용들은 기존에 있던 내용들이고,

맨 밑에 "remote.SSH.remotePlatform" : { "원격서버IP" : "linux" } 라는 내용만 추가

 

아래 위치의 config 파일도 수정해줌.

Host User@원격서버IP:포트번호

    HostName 포트번호

    User 유저네임

    Port 포트번호

 

 

 

수정이 완료되고 vscode를 새로 시작

 

F1 누르고 ssh 검색하면 Remote-SSH:Connect to Host ... 가 뜸. 클릭

 

select 하라고 뜸. 원격서버 클릭

비밀번호 입력하라고 뜸.

비밀번호 입력

 

하면 원격서버로 진입 완료

 

F1 누르고 Remote-container 클릭

 

현재 start 되어있는 도커 container 목록이 뜸. 선택해서 클릭

 

도커 환경 내부로 진입 완료

 

 

ctrl+shift+~ 눌러서 터미널로 작업도 가능.

Comments