Docker Context
여러 Docker endpoint를 이름으로 저장하고 전환하는 docker context 관리 그룹.
Summary
- 로컬 소켓, 원격 SSH, Docker Desktop, Swarm endpoint 등을 context로 분리할 수 있다.
use는 기본 context를 바꾸고, top-level–context옵션은 1회성 오버라이드다.- export/import로 다른 환경에 context 설정을 옮길 수 있다.
Usage
docker context COMMAND
Command Groups
create: 새 context 생성- 주요 옵션:
–docker host=ssh://user@host,–description,–from
ls: context 목록 조회- 주요 옵션:
–format,-q
show: 현재 기본 context 이름 출력use: 기본 context 변경inspect: endpoint와 metadata 확인- 주요 옵션:
-f
update: 기존 context endpoint 수정export: tar archive로 내보내기import: tar 또는 zip에서 가져오기rm: context 삭제
Examples
# SSH endpoint를 context로 등록 docker context create prod --docker host=ssh://deploy@example.com # 현재 기본 context 확인 및 전환 docker context show docker context use prod # 1회성으로만 다른 context 사용 docker --context prod ps
Troubleshooting
use를 바꾸면 이후 기본 명령 대상이 달라진다. 운영 사고 방지를 위해 프롬프트나 쉘 alias에 현재 context를 표시하는 경우가 많다.- 원격 SSH context는 SSH 키, known_hosts, 원격 Docker 권한에 영향을 받는다.
- CI에서는 기본 context를 바꾸기보다
–context로 명시하는 편이 안전하다.
Help
Usage: docker context COMMAND Manage contexts Commands: create Create a context export Export a context to a tar archive FILE or a tar stream on STDOUT. import Import a context from a tar or zip file inspect Display detailed information on one or more contexts ls List contexts rm Remove one or more contexts show Print the name of the current context update Update a context use Set the default docker context Run 'docker context COMMAND --help' for more information on a command.
+
See Also
History
- codex:: 2026-07-06 Added docker context subpage with create, use, export, and remote endpoint notes.