[英]Running docker image does not work
我是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
它成功建立了。
$ 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
步驟2:運行vagrant up
第三步:運行vagrant ssh -c "docker ps"
來查看容器是否還活着。
步驟4:運行vagrant ssh -c "curl localhost:49160"
來查看index.js
是否運行良好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.