我正在尝试从主机访问ftpd服务器
使用ftp localhost
或ftp <my_ip>
但我得到的是ftp: connect: Connection refused
version: '3'
services:
ftpd-server:
container_name: ftpd-server
image: stilliard/pure-ftpd:hardened
ports:
- 21:21
- 20:20
- 30000-30009:30000-30009
volumes:
- './ftp/data:/home/username/'
- './ftp/pass:/etc/pure-ftpd/passwd'
environment:
PUBLICHOST: "0.0.0.0"
FTP_USER_NAME: "user"
FTP_USER_PASS: "pass"
FTP_USER_HOME: "/home/username"
restart: always
由于我使用PUBLICHOST: "0.0.0.0"
和端口转发21:21
,我希望能够连接。
Docker日志
Removing ftpd-server ... done
Removing network mytest_default
No stopped containers
Creating network "mytest_default" with the default driver
Creating ftpd-server ...
Creating ftpd-server ... done
Attaching to ftpd-server
ftpd-server | Creating user...
ftpd-server | Password:
ftpd-server | Enter it again:
ftpd-server | Setting default port range to: 30000:30009
ftpd-server | Setting default max clients to: 5
ftpd-server | Setting default max connections per ip to: 5
ftpd-server | Starting Pure-FTPd:
ftpd-server | pure-ftpd -l puredb:/etc/pure-ftpd/pureftpd.pdb -E -j -R -P 0.0.0.0 -s -A -j -Z -H -4 -E -R -G -X -x -p 30000:30009 -c 5 -C 5
我怎样才能实现从主机连接到我的ftp服务器上的容器?
2条答案
按热度按时间3pmvbmvn1#
您可以将
network_mode: host
添加到服务定义中以使其工作。然后测试:
kkih6yb82#
我这边的一个工作示例如下:
添加行“网络模式:主机”将导致最新Docker安装出现以下错误(对于我的情况,它是Docker版本20.10.13,在Windows 10操作系统上构建a224086,并支持WSL2):
这是新版本Docker中涉及的防护设施,以避免端口配置错误,请查看以下链接了解详细信息:https://forums.docker.com/t/docker-errors-invalidargument-host-network-mode-is-incompatible-with-port-bindings/103492 .