Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use this container for exposing host ports #17

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
# sshd-docker
Docker image with SSH daemon installed

# Usage
This container is meant to be used to expose host ports to containers running in Docker.
When using testcontainers in unit tests, refer to the documentation of testcontainers to find out how to use it:
- Java: https://java.testcontainers.org/features/networking/#exposing-host-ports-to-the-container
- .NET: https://dotnet.testcontainers.org/api/create_docker_network/#exposing-host-ports-to-the-container
- node.js: https://node.testcontainers.org/features/networking/#expose-host-ports-to-container
StefanLobbenmeierObjego marked this conversation as resolved.
Show resolved Hide resolved
- Go: https://golang.testcontainers.org/features/networking/#exposing-host-ports-to-the-container

Alternatively, you can start the container yourself:
```yaml
mdelapenya marked this conversation as resolved.
Show resolved Hide resolved
services:
sshd:
image: testcontainers/sshd:1.2.0
environment:
PASSWORD: "SET_YOUR_PASSWORD_HERE"
ports:
- 10022:22

requester:
image: curlimages/curl
command: /bin/sh -c "while true; do curl http://sshd:8080; sleep 5; done"
depends_on:
- sshd
```

And connect to it via ssh:

```bash
# ssh -R [remote_port]:[destination_address]:[local_port] [username]@[ssh_server] -p [ssh_port]
ssh -R 8080:localhost:8080 root@localhost -p 10022
```

Start your application and you should see requests coming from the requester service:

```bash
python3 -m http.server 8080
```
Loading