기술, 나의 공부를 공유합니다./Docker
6. Docker Run (Create + Start)
욘초
2023. 6. 22. 23:43
Docker Run 명령어는 Create명령어 +Start 명령어 이다.
Create는 Image를 Container로 만드는 동작을 수행하고,
Start는 생성된 Container를 실행 시킨다.
1. Run 명령어 Option (참조 : https://docs.docker.com/engine/reference/commandline/run/ )
- Usage
$ docker run [OPTIONS] IMAGE [COMMAND] [ARG..]
- 일부 Option
- --name : container name
- --rm : remove container when it exits
- --publish, -p : publish a container`s port(s) to the host
- --volume, -v : bind mount a volume
- --interactive, -i : keep STDIN open eve if not attached
- --tty, -t : allocate a pseudo-TTY
- --label, -l : set meta data on a container
2. 예제) apache image(httpd)를 pull 받고, httpd로 container를 생성하는데
container 이름은 “test_httpd”, port 는 “80:80”으로 설정한다.
1. apache image pull (명령어 : $ docker pull httpd)
pull 받고 나서 정상적으로 설치 되었는지 “$ docker images” 명령어로 현재 설치된 image 정보 목록 확인
2. run httpd, name is “test_httpd”, port is “80:80” connection
3. check localhost:80 browser