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, ...
随机推荐
- MySQL系列(五)---总结MySQL中的锁
MySQL中的锁 目录 MySQL系列(一):基础知识大总结 MySQL系列(二):MySQL事务 MySQL系列(三):索引 MySQL系列(四):引擎 概述 MyISAM支持表锁,InnoDB支持 ...
- 虚拟机下克隆3个centos系统并配置IP访问网络(转载)
此文是保证linux系统能够上网 先查看本机的IP 打开虚拟机,更改虚拟机为桥接方式 在第一个虚拟机上打开终端,在命令行输入setup,选择NETWORK CONFIGRATION 回车后, 配置IP ...
- docker - 设置HTTP/HTTPS 代理
背景 将docker的服务器环境切换到新的网络之后,由于服务器的internet是受限制的(需要连接配置远程代理,不能直接上网).因此,在使用docker连接docker hub 的时候,就会出错: ...
- Python爬虫从入门到放弃(二十一)之 Scrapy分布式部署
按照上一篇文章中我们将代码放到远程主机是通过拷贝或者git的方式,但是如果考虑到我们又多台远程主机的情况,这种方式就比较麻烦,那有没有好用的方法呢?这里其实可以通过scrapyd,下面是这个scrap ...
- com.mysql.jdbc.exceptions.MySQLSyntaxErrorException错误
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the ...
- BPM与OA的区别及联系
BPM与OA的区别及联系 近年来,在企业管理信息系统一些名词反复被提及,然而外行人对于这些名词则是一头雾水,网上的解释又鱼龙混杂,没有绝对权威的文献可供参考,因此也就让我们对这些名词的认识越来越模糊. ...
- Vue过渡效果之CSS过渡
前面的话 Vue 在插入.更新或者移除 DOM 时,提供多种不同方式的应用过渡效果.本文将从CSS过渡transition.CSS动画animation及配合使用第三方CSS动画库(如animate. ...
- DB2 HADR备库归档问题
--DB2 HADR备库归档问题 --------------------------------2013/10/29 我们注意到在Oracle DataGuard中,备机中依然会设置LOG_ARCH ...
- 【LeetCode】数组-1(643)-返回规定长度k的最大子数组的平均数
好久没有刷LeetCode了,准备重拾并坚持下去,每天刷个两小时.今天算是开始的第一天,不过出师不利,在一道很简单的题目上墨迹半天.不过还好,现在踩过的坑,应该都不会白踩,这些可能都是以后程序员路上稳 ...
- Charles使用(二)
Charles使用(二) 破解Charles 找到Charles应用-->右键显示包内容--->contents-->java:更换Charles.jar即可 链接: https ...