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, ...
随机推荐
- [js高手之路] es6系列教程 - var, let, const详解
function show( flag ){ console.log( a ); if( flag ){ var a = 'ghostwu'; return a; } else { console.l ...
- 使用Node.js实现简易MVC框架
在使用Node.js搭建静态资源服务器一文中我们完成了服务器对静态资源请求的处理,但并未涉及动态请求,目前还无法根据客户端发出的不同请求而返回个性化的内容.单靠静态资源岂能撑得起这些复杂的网站应用,本 ...
- 一个想法照进现实-《IT连》创业项目:聊聊IT连App是如何思考解决IT人员单身问题的
前言: 根据最早我编写的IT联盟社区众筹计划书的思路方向:社交->资讯=>评级=>培训. 现在在实现第一个阶段中,而且这个阶段可能会走很久. 今天开文,主要是讲述一下,现在的版本为什 ...
- Linux配置全局jdk
Linux配置全局jdk 1.确保相应文件夹下有apache-tomcat和jdk的压缩文件 注意:jdk文件必须为适应Linux版本的文件 (如果已经有了相应文件,可以跳过以下第2-3个步骤) 2. ...
- mysql的内连接,外连接(左外连接,右外连接)巩固
1:mysql的内连接: 内连接(inner join):显示左表以及右表符合连接条件的记录: select a.goods_id,a.goods_name,b.cate_name from tdb_ ...
- 对图像组成不了解?这样学习Matplotlib必走弯路!
在学习Matplotlib的过程中,大家一定会遇到这样那样的问题,比如说,背景图怎么设置?坐标轴怎么设置?坐标轴上的刻度值怎么设置?怎样在PyQt中添加Matplotlib绘图模块? 其实想要学好用好 ...
- HTML5 — Wed Storage简单示例
一.Wed Storage 概述 Wed Storage功能:在Wed上储存数据的功能,这里的储存是针对客户端本地而言的. 具体分为两种: sessionStorage,将数据保存在session对象 ...
- MATLAB匹配按列碎开的纸片
纵向切开的纸片的拼接 2013 CUMCM_B %% paper_cutting.m clear, close all clc %% import pictures, and save into im ...
- CentOS 7 服务器配置--安装nginx
#安装pcre yum install -y pcre-devel #安装zlib-devel yum install -y zlib-devel #下载nginx wget -r -np -nd h ...
- 利用 :before :after伪类实现鼠标悬浮动画效果
1.最近在逛网站的时候,想找一下喜欢的鼠标悬浮效果,避免广告的嫌疑,直接放图了: 2.在实现的时候,如果在直接使用鼠标hover ,transform,进行过渡,不能达到想要的效果,因为同时只能触发一 ...