gpt4 book ai didi

ubuntu - Docker 已启动,但无法在端口 8000 访问 localhost

转载 作者:行者123 更新时间:2023-12-02 21:18:14 25 4
gpt4 key购买 nike

所以我正在尝试设置我的应用程序。

我运行命令sudo docker-compose ps我得到以下输出

enter image description here

看起来一切都已启动并正在运行,但是如果我在端口 8000 访问 localhost,我会看到以下屏幕:

enter image description here

我正在使用 nginx这是我的配置:

    # Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}

请注意,如果我转到 localhost(没有端口号),它会显示我的 nginx 已正确安装(默认 nginx 屏幕)

谁能告诉我我错过了什么?

最佳答案

您需要将端口从主机映射到正在运行的容器。

搬运工运行 -d -p 5801:5801 -p 5802:5802 .....

此外,如果您的工作站/笔记本电脑有多个网卡,请确保将其映射到您尝试从中访问它的正确网卡:

docker run -d -p <interface IP>:<outside port>:<inside port> .....

有关更多信息,请参阅这篇文章:
https://forums.docker.com/t/how-to-expose-port-on-running-container/3252/5

关于ubuntu - Docker 已启动,但无法在端口 8000 访问 localhost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48873382/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com