Amazon web services AWS实例上的连接被拒绝?
我有一个linux AWS实例。我正在运行以下脚本:Amazon web services AWS实例上的连接被拒绝?,amazon-web-services,docker,Amazon Web Services,Docker,我有一个linux AWS实例。我正在运行以下脚本: #!/usr/bin/env bash #This script installs java, sbt and the application #Run this script on a new EC2 instance as the user-data script, which is run by `root` on machine start-up. sudo yum update -y sudo y
#!/usr/bin/env bash
#This script installs java, sbt and the application
#Run this script on a new EC2 instance as the user-data script, which is run by `root` on machine start-up.
sudo yum update -y
sudo yum install -y docker
sudo service docker start
docker run repo/carrie
一切都已安装,我在日志中看到以下消息:
REST interface bound to /0.0.0.0:8080
但是,当我尝试像这样实际访问端口时:
curl 0.0.0.0/8080
我得到以下信息:
Failed to connect to 0.0.0.0 port 8080: Connection refused
我尝试过编辑入站规则,使8080处于打开状态,但似乎不起作用。可能是因为我在实例启动后编辑规则?您必须在
docker run
命令中将容器的端口发布到主机
$ docker run --help
...
-p, --publish list Publish a container's port(s) to the host
...
如果容器中的进程侦听端口80,则脚本的最后一行应该如下所示:
docker run -p 8080:80 repo/carrie
容器有自己的接口,因此主机的0.0.0.0不适用 告诉docker将容器端口8080绑定到主机:
docker run -p 8080:8080 repo/carrie
从哪里卷曲?使用in-in-the-box还是outside?作为根用户,从框内(我已通过ssh插入)只需将
-p 8080:
添加到您的docker run
命令,如我的回答所示。非常感谢您-现在我收到了此错误!无法连接到0.0.0.0端口80:连接被拒绝是否curl本地主机:8080
?可能脚本命令必须如下所示:dockerrun-p8080:808080repo/carrie