运行docker映像不起作用

我是Docker的新手,我正在为Docker做Node.js教程。 我困在这一步: http : //docs.docker.io/en/latest/examples/nodejs_web_app/#building-your-image

我已经执行了这个:

$ docker build -t user/centos-node-hello . ... Successfully built c04aea889b03 

并成功build成。

 $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE user/centos-node-hello latest c04aea889b03 23 minutes ago 667.9 MB ubuntu 13.10 9f676bd305a4 9 weeks ago 178 MB ubuntu saucy 9f676bd305a4 9 weeks ago 178 MB ubuntu raring eb601b8965b8 9 weeks ago 166.5 MB ubuntu 13.04 eb601b8965b8 9 weeks ago 166.5 MB ubuntu 12.10 5ac751e8d623 9 weeks ago 161 MB ubuntu quantal 5ac751e8d623 9 weeks ago 161 MB ubuntu 10.04 9cc9ea5ea540 9 weeks ago 180.8 MB ubuntu lucid 9cc9ea5ea540 9 weeks ago 180.8 MB ubuntu 12.04 9cd978db300e 9 weeks ago 204.4 MB ubuntu latest 9cd978db300e 9 weeks ago 204.4 MB ubuntu precise 9cd978db300e 9 weeks ago 204.4 MB busybox latest 769b9341d937 9 weeks ago 2.489 MB centos 6.4 539c0211cd76 12 months ago 300.6 MB 

现在我尝试运行该图像:

 $ docker run -p 49160:8080 -d user/centos-node-hello 995bfeef4edd723027480fdb43f097e2ba6a97b8fb1d2e9ec679dc1247f68a84 

但是如果我检查进程,实例没有运行。

 $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS 

有任何想法吗? 谢谢。

试试:docker run -p 49160:8080 -i -t / centos-node-hello / bin / bash

有关选项的更多信息: http : //docs.docker.com/reference/run/

不清楚你的执行环境。 我使用Vagrant成功运行了docker-node-hello示例。 请参阅以下步骤。

注意:由于centos:6.4镜像在Docker Hub中不再可用,因此我将基本镜像修改为了centos:6.6

第1步:编辑一个Vagrantfile

 Vagrant.configure(2) do |config| config.vm.box = "williamyeh/ubuntu-trusty64-docker" config.vm.provision "shell", inline: <<-SHELL git clone https://github.com/enokd/docker-node-hello.git cd docker-node-hello sed -i -e 's/centos:6.4/centos:6.6/' Dockerfile docker build -t centos-node-hello . docker run -p 49160:8080 -d centos-node-hello docker ps SHELL end 

第二步:跑上vagrant up

步骤3:运行vagrant ssh -c "docker ps"查看容器是否活着。

第四步:运行vagrant ssh -c "curl localhost:49160"查看index.js是否运行正常。