EXPOSE directive for SSH¶
In the context of containerizing an SSH service, the EXPOSE directive is used within a Dockerfile to inform the Docker engine that the container listens on the specified network port at runtime.^[600-developer-docker-dockerfile-docker-ssh.md]
Usage for SSH¶
When setting up a server that allows SSH connections, the standard port is 22. The directive is explicitly written in the Dockerfile as:
dockerfile
EXPOSE 22^[600-developer-docker-dockerfile-docker-ssh.md]
This declaration serves as documentation for image users and allows linking services to the container, although the port still needs to be published (mapped) to the host when running the container to be accessible from outside the Docker host.^[600-developer-docker-dockerfile-docker-ssh.md]
Related Concepts¶
- Dockerfile
- [[Docker]]
- [[SSH]]
Sources¶
^[600-developer-docker-dockerfile-docker-ssh.md]