티스토리 뷰
Docker
Docker 는 컨테이너를 이용한 가상화 플랫폼이다. 마치 Java VM 이 설치만 되어 있으면 운영체제나 하드웨어의 의존하지 않고 자바 소프트웨어를 구동할 수 있듯이 Docker가 설치되어 있으면 Docker로 빌드된 소프트웨어를 구동할 수 있다. Docker에 대한 자세한 설명과 설치 방법은 생략하고 Pgadmin4 라는 postgresql DB 관리 Tool로 Docker의 기본 명령어를 간단히 알아보겠다.
>docker system info
Docker 의 구체적인 상태 정보등을 확인할수있다.
docker system info
Client:
Debug Mode: false
Server:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 1
Server Version: 19.03.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.184-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952GiB
Name: docker-desktop
ID: 3INB:RHWH:UOYH:7Z3L:A7EO:QVW3:GSTL:C4GY:UX2Q:WQOH:DKMK:USFG
Docker Root Dir: /var/lib/docker
Debug Mode: true
File Descriptors: 39
Goroutines: 56
System Time: 2019-10-22T00:47:14.5450312Z
EventsListeners: 4
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
>docker search pgadmin
Docker Hub Repository 에서 이미지를 검색한다. Start(github 에 스타와 같은 의미), 공식 여부등 정보가 조회된다.
docker search pgadmin
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
dpage/pgadmin4 pgAdmin 4 is a web based administration tool… 418
fenglc/pgadmin4 pgAdmin is an open source administration and… 43
thajeztah/pgadmin4 Simple Docker image for pgAdmin 4. Not inten… 22 [OK]
meedan/pgadmin pgadmin 4 web interface 4 [OK]
foxylion/pgadmin4 PostgreSQL pgAdmin 4 with binary support (ba… 3 [OK]
jdecool/pgadmin PgAdmin in a container 2 [OK]
pivotaldata/pgadmin Multiple docker images that support the regr… 2
huggla/pgadmin-alpine Pgadmin4 on Alpine, with enhanced security. 2 [OK]
vxsoft/pgadmin4 Pgadmin 1 [OK]
zfil/pgadmin3 pgadmin3 from Ubuntu Xenial (16.04 LTS) 1 [OK]
elesdoar/pgadmin4 Dockerized Image for pgAdmin4 1 [OK]
ddidier/pgadmin4 The pgAdmin 4 administration tool for Postgr… 1 [OK]
nphung/pgadmin Docker image for pgAdmin (pgAdmin 4 v1.5 at … 0 [OK]
pgadmin/ripdock 0
pgadmin/ripmain 0
biarms/pgadmin4 A docker image for running PGAdmin on an arm… 0
jouve/pgadmin4 pgadmin4 with python3.6 define PGADMIN_SETUP… 0 [OK]
rekgrpth/pgadmin pgadmin 0 [OK]
stivehu/pgadmin4 pgadmin4 dockerized version 0 [OK]
regiowebapi/pgadmin pgadmin4 0
ddidier/pgadmin The pgAdmin 3 administration tool for Postgr… 0 [OK]
russell/pgadmin4 pgadmin4 container 0 [OK]
bernardelli/pgadmin4 PgAdmin4 local server 0 [OK]
computersciencehouse/pgadmin Dockerized pgAdmin 0 [OK]
appscode/pgadmin
>docker pull
docker hub에 있는 이미지를 로컬에 다운로드한다.
docker pull dpage/pgadmin4
Using default tag: latest
latest: Pulling from dpage/pgadmin4
9d48c3bd43c5: Pull complete
c0ea575d71b9: Pull complete
0f535eceebd5: Pull complete
8a30f5893bea: Pull complete
c1d30ace7b67: Pull complete
07864167d918: Pull complete
93c729eb2d67: Pull complete
6a90a70187ea: Pull complete
f8a53155b1f0: Pull complete
ea53e07e3c59: Pull complete
f5ef29937d52: Pull complete
1b62ccab5a71: Pull complete
db226905ceae: Pull complete
425a6f100488: Pull complete
Digest: sha256:de7c6c8fa54b6b5fbf00fd594623292350856ebe5bad540baa5773aa65b75bb7
Status: Downloaded newer image for dpage/pgadmin4:latest
docker.io/dpage/pgadmin4:latest
> docker run -p 80:80 -e 'PGADMIN_DEFAULT_EMAIL=user@domain.com' -e 'PGADMIN_DEFAULT_PASSWORD=SuperSecret' -d dpage/pgadmin4
내려받은 이미지를 구동한다. -p 80:80 은 로컬 PC 의 80 port 와 docker container 80 port 를 binding 한다는 의미이다. -v 옵션으로 디스크도 마운트 할 수 있다. -e 'PGADMIN_DEFAULT_EMAIL=user@domain.com' 는 어플리케이션에 전달할 환경변수 값이다. -d demon 형태로 구동을 의미하고 dpagd/pgadmin4 는 이미지 명이다.
docker run -p 80:80 -e 'PGADMIN_DEFAULT_EMAIL=user@domain.com' -e 'PGADMIN_DEFAULT_PASSWORD=SuperSecret' -d dpage/pgadmin4
ac8ac037b9e7820b411fdc75a31c5dc36c73a4b327c9d39141288724c6d3df6f
> docker container list
현재 구동중인 container 리스트 확인 -a 옵션으로 stop 되어있는 container 전부를 확인 할 수도 있다.
docker container list
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ac8ac037b9e7 dpage/pgadmin4 "/entrypoint.sh" 33 seconds ago Up 32 seconds 0.0.0.0:80->80/tcp, 443/tcp compassionate_swartz
>docker stats
현재 구동중인 container 의 리소스 사용율을 확인
docker stats
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
ac8ac037b9e7 compassionate_swartz 0.05% 93.02MiB / 1.952GiB 4.65% 1.11kB / 0B 0B / 2.55MB 5
>docker container logs ac8ac037b9e7
container 의 표춘 출력 확인
docker container logs ac8ac037b9e7
NOTE: Configuring authentication for SERVER mode.
[2019-10-22 01:08:22 +0000] [1] [INFO] Starting gunicorn 19.9.0
[2019-10-22 01:08:22 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
[2019-10-22 01:08:22 +0000] [1] [INFO] Using worker: threads
[2019-10-22 01:08:22 +0000] [84] [INFO] Booting worker with pid: 84
>docker container exec -it ac8ac037b9e7 /bin/sh
container 내부 실행 exec 는 실행 명령어를 전달한다. -i 는 대화형 모드 , -t tty 연결 /bin/sh shell 실행 즉 위 명령어는 컨테이너 안으로terminal 을 연결한다.
docker container exec -it ac8ac037b9e7 /bin/sh
/pgadmin4 # ls //container 안에서 ls 명령어 실행
__pycache__ config.py config_distro.py docs migrations pgAdmin4.py pgAdmin4.wsgi pgadmin requirements.txt run_pgadmin.py setup.py
>docker container stop ac8ac037b9e7
container 중단
docker container stop ac8ac037b9e7
ac8ac037b9e7
>docker container start ac8ac037b9e7
container 시작
docker container start ac8ac037b9e7
ac8ac037b9e7
>docker container rm ac8ac037b9e7
docker container 삭제
docker container rm ac8ac037b9e7
ac8ac037b9e7
>docker image ls dpage/pgadmin4
docker 이미지 리스트
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
dpage/pgadmin4 latest 177213947c28 5 days ago 265MB
>docker image rm dpage/pgadmin4
docker image 삭제
docker image rm dpage/pgadmin4
Untagged: dpage/pgadmin4:latest
Untagged: dpage/pgadmin4@sha256:de7c6c8fa54b6b5fbf00fd594623292350856ebe5bad540baa5773aa65b75bb7
Deleted: sha256:177213947c28da62c810a11e4d968b99bf0d38cf29bb4749b6f47df71c105000
Deleted: sha256:fcfb8d606458935c518217aacc2fe16d6ddccce48c517d904207f078236cf06e
Deleted: sha256:85e49d6488491577674c2017d7f3940c40481ee46fed3bb6309badec6d580df3
Deleted: sha256:af51aea1bdd82d1e22b6dd1a68ffa5c20af927ae994ba012bfe355012571fb86
Deleted: sha256:b2a9fe11fe82a773e0ae0d2a1e7ab758dc92bf6a5491ce5acc07003c2973b265
Deleted: sha256:90df4f6897730ef058112c05372f55e61bdc6fe91e9b4ddff9daa7119683a14c
Deleted: sha256:878a372a55c2cb2924877c56b80dac81f4c10d56b0c70769af83ed7ab4b8af20
Deleted: sha256:574443b0bc1e3e83f810682e4cc5dfcf7d078ac00516a96f9a79784dd0423e4e
Deleted: sha256:61d6aa596a825bf76448c1be01802624e39c679cc3562ab699622bca3af628ac
Deleted: sha256:0d900f959cd2addf5b2b84b273c1500fffed8ae548e975e8a8980a30e3878182
Deleted: sha256:e6625f98ac0c8a9846bffd5c6bc1e03f2d304a226e1007f14b1c497eff4dbec5
Deleted: sha256:d29d8196ccaefe8152e00abf39a4dee63f4ac5332b4c33e98fa07e34f19babf9
Deleted: sha256:816d01bd7acfaf270620be8d7eb8519abcc8254f22a21451a1ebcb1cde73f514
Deleted: sha256:eecb32456f471dc2eb0d209190db6e1f0f97040d6d353c16bbec3ce7a366cc07
Deleted: sha256:03901b4a2ea88eeaad62dbe59b072b28b6efa00491962b8741081c5df50c65e0
기타 유용한 명령어
>docker cp ${컨테이터명}:/tmp/test.txt ./test.txt
docker container 안에 파일을 호스트로 복사하기, 반대로 입력하면 호스트에서 container 안으로 파일 복사가 가능하다.
>docker run ${컨테이너명} --entrypoint /bin/bash
기존의 entrypoint 로 설정된 내용을 override 하고 실행 위 샘플 명령어는 bash를 실행한다.
'Web Development' 카테고리의 다른 글
MAC OS에서 파일명 확장자 일괄변경 (0) | 2019.11.04 |
---|---|
python pip install 중 error => locale.Error: unsupported locale setting) (0) | 2019.10.23 |
MySQL(5.x, 8.x) 기초 설치 Ubuntu(16.x), 테이블 용량확인 (0) | 2019.10.04 |
Postgresql 기본 설치, 데이터 스토리지 변경, 삭제 (Ubuntu 16.x) (0) | 2019.09.26 |
VI 편집기 유용한 단축키 및 명령어 (0) | 2019.09.22 |
- Total
- Today
- Yesterday