Docker - Failed to connect to localhost port 4000: Connection refused
按照Docker的安装指导进行操作时,在Get Started, Part 2: Containers这一章,遇到如下问题。
(where you can check up the link here => https://docs.docker.com/get-started/part2/#run-the-app)
我使用了和示例中一致的 Dockerfile, requirements.txt
$ ls
app.py Dockerfile requriements.txt
Dockerfile的内容:
FROM python:2.7-slim
WORKDIR /app
ADD . /app
RUN pip install -r requriements.txt
EXPOSE 80
ENV NAME World
CMD ["python", "app.py"]
三个文件的内容和安装指导中的完全一致。使用如下指令建立镜像也成功了。
All 3 files have file content/code exactly same as the tutorial also. I was able to build image registry with this command
$ docker build -t friendlyhello .
一切看起来很正常,生成了frindlyhello的镜像,可以通过以下指令查看镜像
$ docker images
REPOSITORY TAG IMAGE ID CREATED
friendlyhello latest 82b8a0b52e91 39 minutes ago
python 2.7-slim 1c7128a655f6 5 days ago
hello-world latest 48b5124b2768 4 months ago
运行docker,将80端口映射到4000端口
$ docker run -d -p 4000:80 friendlyhello
使用docker ps指令检查运行状态
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS
c1893f7eea9f friendlyhello "python app.py" 15 minutes ago Up 16 minutes
官方的指导手册说,可以在浏览器中输入地址 http://localhost:4000 来检测docker是否运行
可惜我无法连接到localhost
$ curl http://localhost:4000
curl: (7) Failed to connect to localhost port 4000: Connection refused
//------------------------------------------------------------------------------------------------------------------------------------
解决方案
查询docker-machine使用的默认IP
$ docker-machine ip default
使用查询到的IP在浏览器中
http://.......:4000
或使用curl指令
$ curl http://$(docker-machine ip default):4000
Docker - Failed to connect to localhost port 4000: Connection refused的更多相关文章
- Ubuntu下 ssh : connect to host localhost port 22:Connection refused
Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused 造成这个错误的原因 ...
- 运行Hadoop start-all.sh遇到的错误ssh: connect to host localhost port 22: Connection refused
ssh: connect to host localhost port 22: Connection refused 我的情况是ssh server没装,查看方法: ps -e |grep ssh 1 ...
- ssh: connect to host localhost port 22: Connection refused
1.hadoop安装好之后,执行ssh localhost无法执行, 提示“ssh: connect to host localhost port 22: Connection refused”. 2 ...
- 新手git: ssh: connect to host localhost port 22: Connection refused
由于gitlab上要git pull或者git clone,可是每次都出现这个问题.之前偶尔出现这个问题.可是仅仅是偶尔.这是为什么呢?然后就開始搜索网上的解决方式了. 这个问题搜索网上非常多答案.可 ...
- ssh本机失败(ssh: connect to host localhost port 22: Connection refused)
ssh本机失败(ssh: connect to host localhost port 22: Connection refused) 一. 问题描述 之前一直在服务上使用宝塔面板, 今天突发奇想, ...
- ubuntu安装配置ssh-connect to host localhost port 22: Connection refused
在安装ssh,经常出现 ssh: connect to host localhost port 22: Connection refused 从以下几点去检查: 1.是否安装ssh-server: 打 ...
- mac connect to host localhost port 22: Connection refused
在Mac OS X 10.10.5学习hadoop的过程中,输入命令ssh localhost得到 ssh: connect to host localhost port : Connection r ...
- ssh: connect to host localhost port 22: Connection refused 问题
错误原因:1.sshd 未安装2.sshd 未启动 3.防火墙 4需重新启动ssh 服务 解决方法:1.确定安装sshd: $ sudo apt-get install openssh-server ...
- 使用ssh localhost命令,发生异常ssh: connect to host localhost port 22: Connection refused
使用"ssh localhost"命令,失败: 问题分析如下: 出现这个问题是因为Ubuntu默认没有安装openssh-server.检查是否安装了openssh-server, ...
随机推荐
- ASP.NET Core 源码学习之 Logging[3]:Logger
上一章,我们介绍了日志的配置,在熟悉了配置之后,自然是要了解一下在应用程序中如何使用,而本章则从最基本的使用开始,逐步去了解去源码. LoggerFactory 我们可以在构造函数中注入 ILogge ...
- curl---一款实用的URL命令行网络通讯工具/库
最近一段时间在看朴灵翻译的<深入浅出nodejs>,里面有提到一种脱离浏览器的客户端网络通讯工具,curl命令,自己在电脑上试了一下,感觉非常好用,而且莫名的感觉这是一个非常强大的网络工具 ...
- NYOJ--102--次方求模(快速求幂取模)
次方求模 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 求a的b次方对c取余的值 输入 第一行输入一个整数n表示测试数据的组数(n<100)每组测试只有一 ...
- MySQL-InnoDB引擎
InnoDB存储引擎支持事务,其设计目标主要面向在线事务(OLTP)应用,其特点是: 行锁设计,支持外键,并支持类似于Oracle的非锁定读,即默认读取操作不会产生锁,从MySQL5.5.8 开始,I ...
- 虚拟机安装linux系统不能上网解决方法
周末闲来无事,用虚拟机安装了centos6.5系统,安装成功后发现不能连接网络,然后我就一脸蒙蔽了,无奈之下,只能百度查找问题,幸运的是,我还真找到了解决的方法,根据教程一步步操作,成功了!为了避免以 ...
- table之thead兼容
今天遇到一个小bug,是关于table中thead,tbody,tfoot的兼容问题: 在开发的时候为了方便写样式,我就把表格的标题部分关于th的内容放在了thead中,当然了,我也没有写tbody和 ...
- 专业辟谣----ThinkSNS不仅仅是微博程序!
[摘要]ThinkSNS(简称TS),一款全平台综合性社交系统,为国内外大中小企业和创业者提供社会化软件研发及技术解决方案,目前最新版本为ThinkSNS+. ThinkSNS这个词,第一眼应该想到的 ...
- 实现Qt日志功能并输出到文件(qDebug\qWarning\ qCritical\qFatal)
<1>信息基本分类:qDebug : 调试信息提示qWarning : 一般的警告提示qCritical: 严重错误提示qFatal : 致命错误提示 <2>如何截获这些信息Q ...
- FastJson将json解析成含有泛型对象,内部泛型对象再次解析出错的解决办法(Android)
折腾小半天的问题,这里先感谢一下深圳的小伙子,远程帮我搞,虽然也没有搞出来==========FUCK 声明:Android开发下发生此异常,Java开发下并不会有这个问题 异常重现 简单说一下抛出异 ...
- selenium更加高效的PageObject 对象操作代码
重新封装了的selenium代码,包括click事件,sendkeys事件,select事件,以及对readonly日期控件的处理 package com.common; import java.ut ...