Docker
[Docker] container에 접속하기
Edyo
2023. 3. 16. 16:00
Container ID/Name 확인
$ docker container ls
# 결과 예시
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
123456789010 server1 "~~~" About an hour ago Up About an hour 0.0.0.0:3300->3000/tcp server123
Container 접속
컨테이너의 ID를 입력해도 되고, 컨테이너의 Name을 입력해도 된다.
$ docker exec -it CONTAINER-ID/NAME /bin/bash
- docker exec options
-d, --detach Detached mode: run command in the background
--detach-keys string Override the key sequence for detaching a container
-e, --env list Set environment variables
--env-file list Read in a file of environment variables
-i, --interactive Keep STDIN open even if not attached
--privileged Give extended privileges to the command
-t, --tty Allocate a pseudo-TTY
-u, --user string Username or UID (format: "<name|uid>[:<group|gid>]")
-w, --workdir string Working directory inside the container