Reputation: 8573
Suppose for example that I want to make an SSH host in Docker. I understand that I can EXPOSE 22
inside Dockerfile
. I also understand that I can use -p 22222:22
so I can SSH into that Docker container from another physical machine on my LAN on port 22222 as ssh my_username@docker_host_ip -p 22222:22
. But suppose that I'm so lazy that I can't be bothered to docker run
the container with the option -p 22222:22
every time. Is there a way that the option -p 22222:22 can be automated in a config file somewhere? In
Dockerfile` maybe?
Upvotes: 1
Views: 1844
Reputation: 11772
You can use docker compose
You can defind listening port in docker-compose.yml
file as below:
version: '2'
services:
web:
image: ubuntu
ssh_service:
build: .
command: ssh ....
volumes:
- .:/code
ports:
- "22222:22"
depends_on:
- web
Upvotes: 3