Mac-Osx
docker stack 不會連接到任何容器
並且剛剛執行
docker stack deploy --compose-file docker-stack.yml vote
。我得到的輸出表明容器正在執行:
cchilders:~/tutorials/docker/self-paced-training-beginner-linux-containers/example-voting-app (master) $ docker stack services vote ID NAME MODE REPLICAS IMAGE 27yqy6x84gyk vote_visualizer replicated 1/1 manomarks/visualizer:latest ism6o6nsn9or vote_db replicated 1/1 postgres:9.4 lcklesojqejm vote_result replicated 2/2 dockersamples/examplevotingapp_result:before p0c6q08t8xpo vote_worker replicated 1/1 dockersamples/examplevotingapp_worker:latest we85p3f2fx2z vote_redis replicated 2/2 redis:alpine zv145asbefcu vote_vote replicated 2/2 dockersamples/examplevotingapp_vote:before
教程說您現在可以訪問埠 5000、5001 等,但即使我的容器在堆棧中執行,它們也會失敗。我明白了
This site can’t be reached localhost refused to connect. Search Google for localhost 5001 ERR_CONNECTION_REFUSED
在 Chrome 中嘗試將這些作為頁面打開時,例如
localhost:5000
他們建議您使用的文件是
version: "3" services: redis: image: redis:alpine ports: - "6379" networks: - frontend deploy: replicas: 2 update_config: parallelism: 2 delay: 10s restart_policy: condition: on-failure db: image: postgres:9.4 volumes: - db-data:/var/lib/postgresql/data networks: - backend deploy: placement: constraints: [node.role == manager] vote: image: dockersamples/examplevotingapp_vote:before ports: - 5000:80 networks: - frontend depends_on: - redis deploy: replicas: 2 update_config: parallelism: 2 restart_policy: condition: on-failure result: image: dockersamples/examplevotingapp_result:before ports: - 5001:80 networks: - backend depends_on: - db deploy: replicas: 2 update_config: parallelism: 2 delay: 10s restart_policy: condition: on-failure worker: image: dockersamples/examplevotingapp_worker networks: - frontend - backend deploy: mode: replicated replicas: 1 labels: [APP=VOTING] restart_policy: condition: on-failure delay: 10s max_attempts: 3 window: 120s visualizer: image: manomarks/visualizer ports: - "8080:8080" stop_grace_period: 1m30s volumes: - "/var/run/docker.sock:/var/run/docker.sock" networks: frontend: backend: volumes: db-data:
唯一的步驟是
docker swarm init --advertise-addr $(docker-machine ip) docker stack deploy --compose-file docker-stack.yml vote
從保存的
example-voting-app
目錄docker-stack.yml
如果服務正在執行,為什麼這些埠不打開網頁
vote
?謝謝
當 master 被複製並
docker-compose up
執行時,result
無法建構容器:Building result Step 1/11 : FROM node:5.11.0-slim ---> cb888ea932ad Step 2/11 : WORKDIR /app ---> Using cache ---> d6501817bc62 Step 3/11 : RUN npm install -g nodemon ---> Using cache ---> 33415c41649c Step 4/11 : ADD package.json /app/package.json ---> Using cache ---> a1cf6be1ea33 Step 5/11 : RUN npm config set registry http://registry.npmjs.org ---> Using cache ---> 4d1f7b8fdd8b Step 6/11 : RUN npm install && npm ls ---> Using cache ---> c57c08940ae2 Step 7/11 : RUN mv /app/node_modules /node_modules ---> Running in 0f53a2cdd8e4 mv: cannot remove '/app/node_modules/.bin/mime': No such file or directory mv: cannot remove '/app/node_modules/.bin/semver': No such file or directory mv: cannot remove '/app/node_modules/accepts/HISTORY.md': No such file or directory mv: cannot remove '/app/node_modules/accepts/LICENSE': No such file or directory mv: cannot remove '/app/node_modules/accepts/README.md': No such file or directory mv: cannot remove '/app/node_modules/accepts/index.js': No such file or directory mv: cannot remove '/app/node_modules/accepts/package.json': No such file or directory mv: cannot remove '/app/node_modules/after/.npmignore': No such file or directory mv: cannot remove '/app/node_modules/after/.travis.yml': No such file or directory mv: cannot remove '/app/node_modules/after/LICENCE': No such file or directory mv: cannot remove '/app/node_modules/after/README.md': No such file or directory
當此容器無法執行時,埠 5000 將不會偵聽。
已創建一個問題來解決此問題。