코드코코

[Docker] [환경구성하기] window10 / Docker decktop 설치 및 간단한 명령어 확인 본문

기록/Docker

[Docker] [환경구성하기] window10 / Docker decktop 설치 및 간단한 명령어 확인

코드코코 2022. 6. 3. 10:21

윈도우 10(WSL2) 에 docker desktop 설치

 

1. 계정 등록

https://hub.docker.com/

 

Docker Hub Container Image Library | App Containerization

Build and Ship any Application Anywhere Docker Hub is the world's easiest way to create, manage, and deliver your team's container applications.

hub.docker.com

 

2. Docker desktop 설치

https://docs.docker.com/get-docker/

 

Get Docker

 

docs.docker.com

- 기본 설정 체크 그래도 하면 문제없이 작동함.

 

3. 설치 확인 

$ docker version

PS C:\Users\coco> docker version
Client:
 Cloud integration: v1.0.24
 Version:           20.10.14
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 24 01:53:11 2022
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.8.2 (79419)
 Engine:
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       87a90dc
  Built:            Thu Mar 24 01:46:14 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

 

4. 도커 로그인 

$ docker login

PS C:\Users\coco> docker login
Authenticating with existing credentials...
Login Succeeded

Logging in with your password grants your terminal complete access to your account.
For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/

5. nginx 이미지 받아보기

$ docker pull nginx

PS C:\Users\coco> docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
42c077c10790: Pull complete
62c70f376f6a: Pull complete
915cc9bd79c2: Pull complete
75a963e94de0: Pull complete
7b1fab684d70: Pull complete
db24d06d5af4: Pull complete
Digest: sha256:2bcabc23b45489fb0885d69a06ba1d648aeda973fae7bb981bafbb884165e514
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

 

6. 다운받은 이미지 확인

$ docker images

PS C:\Users\coco> docker images
REPOSITORY           TAG               IMAGE ID       CREATED        SIZE
nginx                latest            0e901e68141f   4 days ago     142MB

 

7. nginx 실행시켜보기

$ docker run -d -p 80:80 --name web nginx

 

# docker run :새로운 컨테이너를 실행하라는 명령
# --detach : 실행되는 컨터이너를 백그라운드로 실행하고 컨테이너 ID를 출력
# --publish=80:80 : 호스트에서 사용하는 port:컨테이너에서 사용하는 port를 80:80 으로 발행
#                   host:80 -> container:80
# --name : docker image 'nginx'를 'web'라는 이름으로 할당

PS C:\Users\coco> docker run -d -p 80:80 --name web nginx
5f5616c55d2fd09b397b9c5524c0b458de68e1541d029532c8027f24aab708a1

 

8. docker 프로세스 확인

$ docker ps

PS C:\Users\coco> docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                NAMES
5f5616c55d2f   nginx     "/docker-entrypoint.…"   26 seconds ago   Up 25 seconds   0.0.0.0:80->80/tcp   web

 

9. docker 실행중인 컨테이너 중지

$ docker rm -f web

PS C:\Users\coco> docker rm -f web
web

 

10. docker 이미지 삭제

$ docker rmi nginx

PS C:\Users\coco> docker rmi nginx
Untagged: nginx:latest
Untagged: nginx@sha256:2bcabc23b45489fb0885d69a06ba1d648aeda973fae7bb981bafbb884165e514
Deleted: sha256:0e901e68141fd02f237cf63eb842529f8a9500636a9419e3cf4fb986b8fe3d5d
Deleted: sha256:1e877fb1acf761377390ab38bbad050a1d5296f1b4f51878c2695d4ecdb98c62
Deleted: sha256:834e54d50f731515065370d1c15f0ed47d2f7b6a7b0452646db80f14ace9b8de
Deleted: sha256:d28ca7ee17ff94497071d5c075b4099a4f2c950a3471fc49bdf9876227970b24
Deleted: sha256:096f97ba95539883af393732efac02acdd0e2ae587a5479d97065b64b4eded8c
Deleted: sha256:de7e3b2a7430261fde88313fbf784a63c2229ce369b9116053786845c39058d5
Deleted: sha256:ad6562704f3759fb50f0d3de5f80a38f65a85e709b77fd24491253990f30b6be