Docker 입문
Tim Sangster
Software Engineer @ DataCamp
hello-world 이미지는 텍스트를 출력하고 종료합니다.
docker run hello-world
Hello from Docker!
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon created a new container from the hello-world image which runs the
executable that produces the output you are currently reading.
3. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
python이 포함된 이미지는 시작 시 python을 실행할 수 있습니다.
docker run python3-sandbox
Python 3.10.6 (main, Nov 2 2022, 18:53:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
...
....
>>> exit()
repl@host:/#
CMD <shell-command>
CMD 지시어:
워크플로를 실행하거나 외부 연결을 수락하는 애플리케이션 시작.
CMD python3 my_pipeline.py
CMD postgres
여러 애플리케이션을 순차로 시작하는 스크립트 실행
CMD start.sh
CMD python3 start_pipeline.py
$$
$$
일반적인 이미지는 더 일반적인 시작 명령이 필요합니다.
이미지 시작
docker run <image>
사용자 지정 시작 명령으로 시작
docker run <image> <shell-command>
사용자 지정 시작 명령으로 대화형 시작
docker run -it <image> <shell-command>
docker run -it ubuntu bash
| 용도 | Dockerfile 지시어 |
|---|---|
| 이미지에서 컨테이너가 시작될 때 실행할 셸 명령 추가 | CMD <shell-command> |
| 용도 | 셸 명령 |
|---|---|
| 이미지에 설정된 CMD 재정의 | docker run <image> <shell-command> |
| CMD를 재정의하고 대화형 실행 | docker run -it <image> <shell-command> |
Docker 입문