250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Jupyter
- sqldeveloper
- 리눅스
- docker
- Python
- 쿼리
- 파이썬
- 복구
- GPU
- cpu
- 시계열
- LOG
- postgre
- 도커이미지
- SQL
- psql
- pgadmin
- psycopg2
- 교차검증
- 오라클
- 연결
- 머신러닝
- jupyternotebook
- oracle
- Linux
- Docker image
- 도커
- Memory
- TensorFlow
- GridSearchCV
Archives
- Today
- Total
areum
[Docker]commit으로 도커 이미지 만드는 방법 본문
728x90
Commit을 통해 이미지 만들기
실습해보기
- 실행된 컨테이너에 git 설치
- ubuntu + git이 설치된 컨테이너를 commit하여 이미지 생성dockedocke
- 3의 이미지로 2개의 컨테이너를 실행하여 각각 python, node.js를 설치
그전에 commit에 대해 간략한 설명 !
아래 그림과 같이 ubutu 이미지를 다운 받은 후 컨테이너를 생성하여 해당 컨테이너에 새로운 패키지 (ex:git) 설치 후 다시 이미지로 commit하면 새로운 이미지가 생성되는 것입니다. (처음 이미지 다운로드는 아래 사이트 들어가서 원하시는 이미지 pull 해오면 될거같습니다 !!)
Docker Hub Container Image Library | App Containerization
Deliver your business through Docker Hub Package and publish apps and plugins as containers in Docker Hub for easy download and deployment by millions of Docker users worldwide.
hub.docker.com
1. ubuntu로 이미지 실행
# ubuntu 이미지 다운로드
$ docker pull ubuntu
# 이미지 다운로드 확인
$ docker images
# my-ubuntu라는 컨테이너명으로 실행 (실행하자마자 bash 터미널에 연결 유지하기)
$ docker run -it --name my-ubuntu ubuntu bash
# 컨테이너 잘 만들어졌는지 확인
$ docker ps
2. 실행된 컨테이너에 git설치하기
# apt 갱신
$ apt update;
# git 설치
$ apt install git
3. ubuntu + git이 설치된 컨테이너를 commit하여 이미지 생성
# 컨테이너 bash 연결 종료
$ exit
# commit
# docker commit <컨테이너명> <리포지토리-이미지이름>:<태그>
$ docker commit my-ubuntu monadk:ubuntu-git
# 생성되었는지 확인
# monadk 리포지토리, ubuntu-git이라는 태그로 이미지 생성되어 있음
$ docker images
# 이미지 삭제
$ docker rmi {옵션} {이미지id} -- 컨테이너가 있을 시 강제 삭제: -f 옵션 사용
4. 2개의 컨테이너로 실행하여 각각 python, node.js를 설치
- nodejs
# monadk:ubuntu-git 이미지를 nodejs라는 컨테이너명으로 실행
$ docker run -it --name nodejs monadk:ubuntu-git bash
# 컨테이너 삭제
$ docker rm {컨테이너 id 또는 이름}
# bash터미널 - nodejs 설치
$ apt update && apt install nodejs
#실행 테스트 - 각각이 독립된 환경
$ nodejs --실행됨
$ python -- command not found
- python
# monadk:ubuntu-git 이미지를 python 컨테이너명으로 실행
$ docker run -it --name python monadk:ubuntu-git bash
# bash터미널 - python 설치
$ apt update && apt install python
# 실행 테스트 - 각각이 독립된 실행환경
$ python -- 실행됨
$ nodejs -- command not found
'Docker' 카테고리의 다른 글
[Docker] 도커 허브에 업로드 하는 방법 (0) | 2022.11.17 |
---|---|
[Docker]도커 이미지 & 컨테이너 중지 및 삭제 등 명령어 모음집 (0) | 2022.11.17 |
[Docker] dokerfile & build를 통해 이미지 만들기 (0) | 2022.11.17 |
[Docker] 도커에 mysql 설치하는 방법 (0) | 2022.07.20 |
[Docker]도커에서 DB접속하여 테이블 만드는 방법 (0) | 2022.07.20 |