Docker 입문
Tim Sangster
Software Engineer @ DataCamp
| 명령 | 사용법 |
|---|---|
| nano <file-name> | <file-name>을 nano 편집기로 엽니다 |
| touch <file-name> | 지정한 이름의 빈 파일을 생성합니다 |
| echo "<text>" | <text>를 콘솔에 출력합니다 |
| <command> >> <file> | <command>의 출력을 <file> 끝에 추가합니다 |
| <command> -y | <command>의 모든 프롬프트에 자동으로 예로 응답합니다 |
docker로 시작합니다.
docker run <image-name>
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.
docker run <image-name>
docker run ubuntu
repl@host:/# docker run ubuntu
repl@host:/#
docker run에 -it를 추가하면 시작된 컨테이너에서 대화형 셸을 사용할 수 있습니다.
docker run -it <image-name>
docker run -it ubuntu
docker run -it ubuntu
repl@container:/#
repl@container:/# exit
exit
repl@host:/#
docker run에 -d를 추가하면 컨테이너가 백그라운드에서 실행되어 셸 제어권이 돌아옵니다.
docker run -d <image-name>
docker run -d postgres
repl@host:/# docker run -d postgres
4957362b5fb7019b56470a99f52218e698b85775af31da01958bab198a32b072
repl@host:/#
docker ps
repl@host:/# docker ps
CONTAINER ID IMAGE COMMAND CREATED
4957362b5fb7 postgres "docker-entrypoint.s…" About a minute ago
STATUS PORTS NAMES
Up About a minute 5432/tcp awesome_curie
docker stop <container-id>
repl@host:/# docker stop cf91547fd657
cf91547fd657
| 사용 | 명령 |
|---|---|
| 컨테이너 시작 | docker run <image-name> |
| 대화형 컨테이너 시작 | docker run -it <image-name> |
| 분리 모드로 시작 | docker run -d <image-name> |
| 실행 중 컨테이너 목록 | docker ps |
| 컨테이너 중지 | docker stop <container-id> |
Docker 입문