윈도우 환경(windows 10)에서 도커 우분투 컨테이너 실행 및 shell 접속 방법
*현재 환경 구성은 윈도우즈 10에 wsl2설치 및 docker desktop 설치까지 완료한 상태임
윈도우즈에서 wsl2 설치 및 docker desktop 설치는 아래 마소 사이트 참고.
https://learn.microsoft.com/ko-kr/windows/wsl/tutorials/wsl-containers
아래 명령어로 우분투 컨테이너 실행
$ docker run -it ubuntu /bin/bash
일단 로컬에서 우분투 이미지를 찾아 실행하는데, 현재 없으므로 도커 허브에서 우분투 latest 버전을 pull하여 자동으로 설치한다.
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
6e3729cf69e0: Pull complete
Digest: sha256:27cb6e6ccef575a4698b66f5de06c7ecd61589132d5a91d098f7f3f9285415a9
Status: Downloaded newer image for ubuntu:latest
설치가 완료되면 바로 우분투 접속..
root@798347de16f5:/# vi
bash: vi: command not found
vi 실행시 "vi command not found"..
vi가 없으므로, vi를 설치하자
vi설치를 위해 우분투 패키지 설치 및 vim 설치 진행
*apt (Advanced Packaging Tool)는 우분투를 포함한 데비안 계열의 리눅스 패키지 설치 도구!
apt-get update
apt-get install vim
apt-get upate 명령 실행 결과.. 패키지 설치 완료
root@798347de16f5:/# apt-get update
Get:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [631 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [17.5 MB]
Get:7 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [786 kB]
Get:8 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [4732 B]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [700 kB]
Get:10 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages [164 kB]
Get:11 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [266 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages [1792 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1011 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [8978 B]
Get:15 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [679 kB]
Get:16 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [988 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 Packages [3520 B]
Get:18 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [7286 B]
Fetched 25.1 MB in 1min 37s (259 kB/s)
Reading package lists... Done
apt-get install vim 명령 실행.. vi 설치 완료!!
root@798347de16f5:/# apt-get install vim
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libexpat1 libgpm2 libmpdec3 libpython3.10 libpython3.10-minimal libpython3.10-stdlib libreadline8 libsodium23
libsqlite3-0 media-types readline-common vim-common vim-runtime xxd
Suggested packages:
gpm readline-doc ctags vim-doc vim-scripts
The following NEW packages will be installed:
libexpat1 libgpm2 libmpdec3 libpython3.10 libpython3.10-minimal libpython3.10-stdlib libreadline8 libsodium23
libsqlite3-0 media-types readline-common vim vim-common vim-runtime xxd
0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.5 MB of archives.
After this operation, 61.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libexpat1 amd64 2.4.7-1ubuntu0.2 [91.0 kB]
중략..........
이미 실행(run) 상태인 컨테이너는 아래와 같이 exec 명령어 및 컨테이너 아이디를 명시하여 shell 접속이 가능하다
docker ps 명령어로 현재 실행중인 컨테이너 아이디 확인 후 exec 명령어로 접속
실행중인 컨테이너 확인 명령어
docker ps
C:\Users\*****> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
798347de16f5 ubuntu "/bin/bash" 59 minutes ago Up 10 minutes friendly_swartz
실행중인 컨테이너 shell 접속 명령어
docker exec -it CONTAINER_ID /bin/bash
docker exec -it 798347de16f5 /bin/bash
OS 버전 확인
cat /etc/issue
root@98f4d7b92db9:/# cat /etc/issue
Ubuntu 22.04.1 LTS \n \l
댓글