[英]Add gitlab ssh public key to known host in dockerfile behind corporate firewall (no port 22)
[英]Expose and publish a port with specified host port number inside Dockerfile
例如,假设我想在Docker中建立一个SSH主机。 我知道我可以在Dockerfile
EXPOSE 22
。 我也了解我可以使用-p 22222:22
因此可以从我的LAN在端口22222上的另一台物理计算机上通过ssh my_username@docker_host_ip -p 22222:22
SSH到该Docker容器中。 但是,假设我是如此懒惰,以至于我每次都不必为docker run
带有-p 22222:22
选项的容器而烦恼。 有没有办法-p 22222:22 can be automated in a config file somewhere? In
选项-p 22222:22 can be automated in a config file somewhere? In
-p 22222:22 can be automated in a config file somewhere? In
Dockerfile中吗?
您可以使用docker compose
您可以在docker-compose.yml
文件中定义监听端口,如下所示:
version: '2'
services:
web:
image: ubuntu
ssh_service:
build: .
command: ssh ....
volumes:
- .:/code
ports:
- "22222:22"
depends_on:
- web
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.