docker 사용법
1. docker images 확인
(hjhan03-sample-django) root@aidw-008:/home/aidw/work_han/hjhan03-sample-airnd-api-template# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> e9094fcbc348 6 hours ago 914MB
python 3.7 53c4b920ae84 3 days ago 903MB
nginx 1.19 08393e824c32 13 months ago 132MB
mongo latest aa22d67221a0 13 months ago 493MB
mongo-express latest 323f84fbaf9b 13 months ago 130MB
k8s.gcr.io/kube-proxy v1.18.6 c3d62d6fe412 13 months ago 117MB
k8s.gcr.io/kube-apiserver v1.18.6 56acd67ea15a 13 months ago 173MB
k8s.gcr.io/kube-controller-manager v1.18.6 ffce5e64d915 13 months ago 162MB
2. 실행중인 docker 확인
(hjhan03-sample-django) root@aidw-008:/home/aidw/work_han/hjhan03-sample-airnd-api-template# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3bd5691e7b8a 642ea549c9bd "sh ./docker_build.sh" 14 minutes ago Exited (2) 14 minutes ago inspiring_montalcini
2ed4807a042c 642ea549c9bd "sh ./docker_build.sh" 4 hours ago Exited (2) 4 hours ago confident_rosalind
704e14b0774e e9094fcbc348 "/bin/sh -c 'apt-get…" 6 hours ago Exited (100) 6 hours ago laughing_sammet
223b4097d3eb redis "docker-entrypoint.s…" 14 months ago Exited (0) 12 months ago some-redis
de70324f7755 gitlab/gitlab-ce:latest "/assets/wrapper" 17 months ago Up 5 days (healthy) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:2222->22/tcp gitlab
e283b5daaaf0 mongo:4.0 "docker-entrypoint.s…" 21 months ago Up 5 days 27017/tcp wekan-db
fb93fb71df07 wiseosho/hadoop:interm "/bin/bash" 2 years ago Exited (255) 2 years ago hadoop
3. docker build
(hjhan03-sample-django) root@aidw-008:/home/aidw/work_han/hjhan03-sample-airnd-api-template# docker build -t hjhan03-sample-airnd-api-template .
Sending build context to Docker daemon 10.89MB
Step 1/9 : FROM python:3.7
---> 53c4b920ae84
Step 2/9 : ENV APP_DIR_PATH /home/cafe24_deploy/hjhan03-sample-airnd_api_template
---> Running in 8bb222b1eef9
Removing intermediate container 8bb222b1eef9
---> bf5f4e32cb57
Step 3/9 : RUN mkdir -p $APP_DIR_PATH
---> Running in 444d9ed8cef6
Removing intermediate container 444d9ed8cef6
---> 1ac53346d4b8
Step 4/9 : COPY . $APP_DIR_PATH
---> 8918b7101e04
Step 5/9 : WORKDIR $APP_DIR_PATH/airnd_api_template/app
---> Running in 2af4621395ec
Removing intermediate container 2af4621395ec
---> ab5c3a6babd9
Step 6/9 : RUN mkdir -p $APP_DIR_PATH/airnd_api_template/app/logs
---> Running in 48bdfadab694
Removing intermediate container 48bdfadab694
---> e45855d6d4c3
Step 7/9 : RUN apt-get update -y && apt-get upgrade -y && apt-get clean
---> Running in 671c7f1efb23
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Removing intermediate container 671c7f1efb23
---> 1fe54fef4ca1
Step 8/9 : EXPOSE 3000
---> Running in 69b67d8c7f01
Removing intermediate container 69b67d8c7f01
---> 4d8ba45878ac
Step 9/9 : CMD ["sh", "./docker_build.sh"]
---> Running in 4f844486dcee
Removing intermediate container 4f844486dcee
---> 106398f84910
Successfully built 106398f84910
Successfully tagged hjhan03-sample-airnd-api-template:latest
4. docker run
- 기본 format
$ docker run (<옵션>) <이미지 식별자> (<명령어>) (<인자>)
- port 사용시
docker run -it -p [외부port]:[컨테이너 내부port] --name [컨테이너 이름] [image id] /bin/bash
5. docker container remove
-기본 format
docker image rm [OPTIONS] IMAGE [IMAGE...]
-ex
docker image rm -f hjhan03-sample-airnd-api-template
6. docker image remove
docker rmi <your-image-id>
6. docker exec
- 내부 실행
docker exec -it c456623003b1 /bin/bash
reference
Author And Source
이 문제에 관하여(docker 사용법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@hanovator/docker-사용법저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)